
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>c++ · Aivin开发笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Aivin">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-versions-select/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-local-video/video-js.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="c++基础.html" />
    
    
    <link rel="prev" href="../c语言/c基础.html" />
    

    
        <link rel="shortcut icon" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    项目说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../linux/linux基础.html">
            
                <a href="../linux/linux基础.html">
            
                    
                    linux
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../linux/linux基础.html">
            
                <a href="../linux/linux基础.html">
            
                    
                    linux基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../linux/android底层开发.html">
            
                <a href="../linux/android底层开发.html">
            
                    
                    android底层开发
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../c语言/c基础.html">
            
                <a href="../c语言/c基础.html">
            
                    
                    c
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../c语言/c基础.html">
            
                <a href="../c语言/c基础.html">
            
                    
                    c基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter active" data-level="1.4" data-path="c++基础.html">
            
                <a href="c++基础.html">
            
                    
                    c++
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.4.1" data-path="c++基础.html">
            
                <a href="c++基础.html">
            
                    
                    c++基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../QT/QT基础.html">
            
                <a href="../QT/QT基础.html">
            
                    
                    QT
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../QT/QT基础.html">
            
                <a href="../QT/QT基础.html">
            
                    
                    QT基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../jni/JNI基础.html">
            
                <a href="../jni/JNI基础.html">
            
                    
                    JNI
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../jni/JNI基础.html">
            
                <a href="../jni/JNI基础.html">
            
                    
                    JNI基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../jni/JNI例子.html">
            
                <a href="../jni/JNI例子.html">
            
                    
                    JNI例子
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../SDL/SDL基础.html">
            
                <a href="../SDL/SDL基础.html">
            
                    
                    SDL
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../SDL/SDL基础.html">
            
                <a href="../SDL/SDL基础.html">
            
                    
                    SDL基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../ffmpeg/ffmpeg基础.html">
            
                <a href="../ffmpeg/ffmpeg基础.html">
            
                    
                    ffmpeg
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../ffmpeg/ffmpeg基础.html">
            
                <a href="../ffmpeg/ffmpeg基础.html">
            
                    
                    ffmpeg基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../ffmpeg/ffmpeg示例代码.html">
            
                <a href="../ffmpeg/ffmpeg示例代码.html">
            
                    
                    ffmpeg示例代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../ffmpeg/ffmpeg软解rtsp简单直播.html">
            
                <a href="../ffmpeg/ffmpeg软解rtsp简单直播.html">
            
                    
                    ffmpeg软解rtsp简单直播
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../ffmpeg/rtsp服务器.html">
            
                <a href="../ffmpeg/rtsp服务器.html">
            
                    
                    rtsp服务器Windows
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../opencv/opencv模块.html">
            
                <a href="../opencv/opencv模块.html">
            
                    
                    opencv模块
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../opencv/opencv.html">
            
                <a href="../opencv/opencv.html">
            
                    
                    opencv
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../openSLES/openSLES基础.html">
            
                <a href="../openSLES/openSLES基础.html">
            
                    
                    openSLES
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../openSLES/openSLES基础.html">
            
                <a href="../openSLES/openSLES基础.html">
            
                    
                    openSLES基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../SoundTouch/移植SoundTouch.html">
            
                <a href="../SoundTouch/移植SoundTouch.html">
            
                    
                    SoundTouch
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../SoundTouch/移植SoundTouch.html">
            
                <a href="../SoundTouch/移植SoundTouch.html">
            
                    
                    移植SoundTouch
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../SoundTouch/实现音频变速和变调.html">
            
                <a href="../SoundTouch/实现音频变速和变调.html">
            
                    
                    实现音频变速和变调
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../openGLES/openGLES基础.html">
            
                <a href="../openGLES/openGLES基础.html">
            
                    
                    openGLES模块
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../openGLES/openGLES基础.html">
            
                <a href="../openGLES/openGLES基础.html">
            
                    
                    openGLES基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../openGLES/GLSL基础.html">
            
                <a href="../openGLES/GLSL基础.html">
            
                    
                    GLSL基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="../openGLES/openglES示例.html">
            
                <a href="../openGLES/openglES示例.html">
            
                    
                    openglES示例
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../视频相关/音视频基础.html">
            
                <a href="../视频相关/音视频基础.html">
            
                    
                    音视频术语-文件格式-协议
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../视频相关/音视频基础.html">
            
                <a href="../视频相关/音视频基础.html">
            
                    
                    音视频基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../视频相关/RTSP.html">
            
                <a href="../视频相关/RTSP.html">
            
                    
                    RTSP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" data-path="../视频相关/RTP.html">
            
                <a href="../视频相关/RTP.html">
            
                    
                    RTP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.4" data-path="../视频相关/RTCP.html">
            
                <a href="../视频相关/RTCP.html">
            
                    
                    RTCP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.5" data-path="../视频相关/H264.html">
            
                <a href="../视频相关/H264.html">
            
                    
                    H264
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.6" data-path="../视频相关/YUV.html">
            
                <a href="../视频相关/YUV.html">
            
                    
                    YUV
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.7" data-path="../视频相关/SurfaceView.html">
            
                <a href="../视频相关/SurfaceView.html">
            
                    
                    SurfaceView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.8" data-path="../视频相关/RTMP.html">
            
                <a href="../视频相关/RTMP.html">
            
                    
                    RTMP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.9" data-path="../视频相关/AAC详解.html">
            
                <a href="../视频相关/AAC详解.html">
            
                    
                    AAC详解
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../音视频相关代码/音视频相关代码.html">
            
                <a href="../音视频相关代码/音视频相关代码.html">
            
                    
                    音视频相关代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../ndk/NDK编译基础.html">
            
                <a href="../ndk/NDK编译基础.html">
            
                    
                    NDK工程编译
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.1" data-path="../ndk/NDK编译基础.html">
            
                <a href="../ndk/NDK编译基础.html">
            
                    
                    NDK编译基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2" data-path="../ndk/cmake方式.html">
            
                <a href="../ndk/cmake方式.html">
            
                    
                    cmake
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3" data-path="../ndk/Android.mk模板.html">
            
                <a href="../ndk/Android.mk模板.html">
            
                    
                    Android.mk
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4" data-path="../ndk/Application.mk模板.html">
            
                <a href="../ndk/Application.mk模板.html">
            
                    
                    Application.mk
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >c++</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#cpp&#x57FA;&#x7840;"><b>1. </b>cpp&#x57FA;&#x7840;</a></li><ul><li><span class="title-icon "></span><a href="#&#x6570;&#x636E;&#x7C7B;&#x578B;"><b>1.1. </b>&#x6570;&#x636E;&#x7C7B;&#x578B;</a></li><li><span class="title-icon "></span><a href="#&#x5173;&#x952E;&#x5B57;"><b>1.2. </b>&#x5173;&#x952E;&#x5B57;</a></li><li><span class="title-icon "></span><a href="#&#x7BAD;&#x5934;-----&#x548C;--&#x70B9;&#x53F7;--&#x64CD;&#x4F5C;&#x7B26;"><b>1.3. </b>&#x201C;&#x7BAD;&#x5934; -&gt; &#x201D;  &#x548C;&#x201C;  &#x70B9;&#x53F7; . &#x201D;&#x64CD;&#x4F5C;&#x7B26;</a></li><li><span class="title-icon "></span><a href="#&#x524D;&#x7F00;-&#x3001;-&#x540E;&#x7F00;"><b>1.4. </b>&#x524D;&#x7F00; &#x3001; &#x540E;&#x7F00;</a></li><li><span class="title-icon "></span><a href="#&#x9884;&#x5904;&#x7406;"><b>1.5. </b>&#x9884;&#x5904;&#x7406;</a></li><li><span class="title-icon "></span><a href="#&#x5E38;&#x91CF;"><b>1.6. </b>&#x5E38;&#x91CF;</a></li><li><span class="title-icon "></span><a href="#&#x53D8;&#x91CF;&#x58F0;&#x660E;-&#x3001;&#x53D8;&#x91CF;&#x5B9A;&#x4E49;"><b>1.7. </b>&#x53D8;&#x91CF;&#x58F0;&#x660E; &#x3001;&#x53D8;&#x91CF;&#x5B9A;&#x4E49;</a></li><ul><li><span class="title-icon "></span><a href="#&#x53D8;&#x91CF;&#x521D;&#x59CB;&#x5316;"><b>1.7.1. </b>&#x53D8;&#x91CF;&#x521D;&#x59CB;&#x5316;</a></li></ul><li><span class="title-icon "></span><a href="#&#x5DE6;&#x503C;&#x3001;&#x53F3;&#x503C;"><b>1.8. </b>&#x5DE6;&#x503C;&#x3001;&#x53F3;&#x503C;</a></li><li><span class="title-icon "></span><a href="#&#x5F02;&#x5E38;"><b>1.9. </b>&#x5F02;&#x5E38;</a></li><li><span class="title-icon "></span><a href="#&#x53CB;&#x5143;&#x51FD;&#x6570;-&#x3001;&#x53CB;&#x5143;&#x7C7B;"><b>1.10. </b>&#x53CB;&#x5143;&#x51FD;&#x6570; &#x3001;&#x53CB;&#x5143;&#x7C7B;</a></li><li><span class="title-icon "></span><a href="#&#x7EE7;&#x627F;"><b>1.11. </b>&#x7EE7;&#x627F;</a></li><li><span class="title-icon "></span><a href="#&#x51FD;&#x6570;&#x91CD;&#x8F7D;"><b>1.12. </b>&#x51FD;&#x6570;&#x91CD;&#x8F7D;</a></li><li><span class="title-icon "></span><a href="#&#x64CD;&#x4F5C;&#x7B26;&#x91CD;&#x8F7D;-&#x3001;-&#x8FD0;&#x7B97;&#x7B26;&#x91CD;&#x8F7D;"><b>1.13. </b>&#x64CD;&#x4F5C;&#x7B26;&#x91CD;&#x8F7D; &#x3001; &#x8FD0;&#x7B97;&#x7B26;&#x91CD;&#x8F7D;</a></li><li><span class="title-icon "></span><a href="#&#x6307;&#x9488;"><b>1.14. </b>&#x6307;&#x9488;</a></li><li><span class="title-icon "></span><a href="#&#x5F15;&#x7528;"><b>1.15. </b>&#x5F15;&#x7528;</a></li><ul><li><span class="title-icon "></span><a href="#&#x6307;&#x9488;&#x4E0E;&#x5F15;&#x7528;&#x7684;&#x533A;&#x522B;"><b>1.15.1. </b>&#x6307;&#x9488;&#x4E0E;&#x5F15;&#x7528;&#x7684;&#x533A;&#x522B;</a></li></ul><li><span class="title-icon "></span><a href="#&#x8F93;&#x5165;&#x8F93;&#x51FA;"><b>1.16. </b>&#x8F93;&#x5165;&#x8F93;&#x51FA;</a></li><li><span class="title-icon "></span><a href="#&#x7C7B;&#x578B;&#x8F6C;&#x6362;"><b>1.17. </b>&#x7C7B;&#x578B;&#x8F6C;&#x6362;</a></li><li><span class="title-icon "></span><a href="#&#x4F20;&#x503C;&#x53C2;&#x6570;--&#x5F15;&#x7528;&#x53C2;&#x6570;"><b>1.18. </b>&#x4F20;&#x503C;&#x53C2;&#x6570;  &#x5F15;&#x7528;&#x53C2;&#x6570;</a></li><li><span class="title-icon "></span><a href="#&#x6A21;&#x677F;"><b>1.19. </b>&#x6A21;&#x677F;</a></li><ul><li><span class="title-icon "></span><a href="#&#x51FD;&#x6570;&#x6A21;&#x677F;"><b>1.19.1. </b>&#x51FD;&#x6570;&#x6A21;&#x677F;</a></li><li><span class="title-icon "></span><a href="#&#x7C7B;&#x6A21;&#x677F;"><b>1.19.2. </b>&#x7C7B;&#x6A21;&#x677F;</a></li></ul><li><span class="title-icon "></span><a href="#&#x547D;&#x540D;&#x7A7A;&#x95F4;"><b>1.20. </b>&#x547D;&#x540D;&#x7A7A;&#x95F4;</a></li><li><span class="title-icon "></span><a href="#&#x6570;&#x7EC4;"><b>1.21. </b>&#x6570;&#x7EC4;</a></li><li><span class="title-icon "></span><a href="#&#x5B57;&#x7B26;&#x4E32;"><b>1.22. </b>&#x5B57;&#x7B26;&#x4E32;</a></li><li><span class="title-icon "></span><a href="#&#x52A8;&#x6001;&#x5185;&#x5B58;"><b>1.23. </b>&#x52A8;&#x6001;&#x5185;&#x5B58;</a></li><li><span class="title-icon "></span><a href="#&#x7ED3;&#x6784;&#x4F53;"><b>1.24. </b>&#x7ED3;&#x6784;&#x4F53;</a></li><li><span class="title-icon "></span><a href="#union-&#x8054;&#x5408;&#x4F53;"><b>1.25. </b>Union &#x8054;&#x5408;&#x4F53;</a></li><li><span class="title-icon "></span><a href="#enum-&#x679A;&#x4E3E;"><b>1.26. </b>enum &#x679A;&#x4E3E;</a></li><li><span class="title-icon "></span><a href="#&#x522B;&#x540D;"><b>1.27. </b>&#x522B;&#x540D;</a></li><li><span class="title-icon "></span><a href="#&#x7C7B;class-&#x3001;&#x5BF9;&#x8C61;"><b>1.28. </b>&#x7C7B;class &#x3001;&#x5BF9;&#x8C61;</a></li><li><span class="title-icon "></span><a href="#stl"><b>1.29. </b>STL</a></li><li><span class="title-icon "></span><a href="#&#x683C;&#x5F0F;&#x5316;&#x65F6;&#x95F4;"><b>1.30. </b>&#x683C;&#x5F0F;&#x5316;&#x65F6;&#x95F4;</a></li><li><span class="title-icon "></span><a href="#&#x6790;&#x6784;&#x51FD;&#x6570;"><b>1.31. </b>&#x6790;&#x6784;&#x51FD;&#x6570;</a></li><li><span class="title-icon "></span><a href="#stdstring-&#x5B57;&#x7B26;&#x4E32;"><b>1.32. </b>std::string &#x5B57;&#x7B26;&#x4E32;</a></li><li><span class="title-icon "></span><a href="#stdpair"><b>1.33. </b>std::pair</a></li><li><span class="title-icon "></span><a href="#stdmap"><b>1.34. </b>std::map</a></li><li><span class="title-icon "></span><a href="#&#x94FE;&#x8868;"><b>1.35. </b>&#x94FE;&#x8868;</a></li><li><span class="title-icon "></span><a href="#c&#x961F;&#x5217;-stddeque"><b>1.36. </b>c++&#x961F;&#x5217; std::deque</a></li><ul><li><span class="title-icon "></span><a href="#&#x961F;&#x5217;&#x4F7F;&#x7528;"><b>1.36.1. </b>&#x961F;&#x5217;&#x4F7F;&#x7528;</a></li></ul><li><span class="title-icon "></span><a href="#&#x7F6E;&#x7A7A;&#x64CD;&#x4F5C;-void"><b>1.37. </b>&#x7F6E;&#x7A7A;&#x64CD;&#x4F5C; (void)</a></li><li><span class="title-icon "></span><a href="#&#x591A;&#x7EBF;&#x7A0B;"><b>1.38. </b>&#x591A;&#x7EBF;&#x7A0B;</a></li><li><span class="title-icon "></span><a href="#&#x6587;&#x4EF6;&#x64CD;&#x4F5C;"><b>1.39. </b>&#x6587;&#x4EF6;&#x64CD;&#x4F5C;</a></li><ul><li><span class="title-icon "></span><a href="#&#x6743;&#x9650;&#x8BF4;&#x660E;"><b>1.39.1. </b>&#x6743;&#x9650;&#x8BF4;&#x660E;</a></li><li><span class="title-icon "></span><a href="#&#x8BFB;&#x53D6;-txt"><b>1.39.2. </b>&#x8BFB;&#x53D6; txt</a></li><li><span class="title-icon "></span><a href="#&#x5199;&#x5165;-txt"><b>1.39.3. </b>&#x5199;&#x5165; txt</a></li><li><span class="title-icon "></span><a href="#&#x4E8C;&#x8FDB;&#x5236;&#x6587;&#x4EF6;-&#x590D;&#x5236;"><b>1.39.4. </b>&#x4E8C;&#x8FDB;&#x5236;&#x6587;&#x4EF6; &#x590D;&#x5236;</a></li></ul><li><span class="title-icon "></span><a href="#&#x6DF7;&#x5408;&#x7F16;&#x7A0B;"><b>1.40. </b>&#x6DF7;&#x5408;&#x7F16;&#x7A0B;</a></li><ul><li><span class="title-icon "></span><a href="#c-&#x6587;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528;-c&#x4EE3;&#x7801;"><b>1.40.1. </b>c++ &#x6587;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528; c&#x4EE3;&#x7801;</a></li><li><span class="title-icon "></span><a href="#c-&#x6587;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528;-c-&#x4EE3;&#x7801;"><b>1.40.2. </b>c &#x6587;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528; c++ &#x4EE3;&#x7801;</a></li></ul><li><span class="title-icon "></span><a href="#&#x7F51;&#x7EDC;&#x8BBF;&#x95EE;"><b>1.41. </b>&#x7F51;&#x7EDC;&#x8BBF;&#x95EE;</a></li><li><span class="title-icon "></span><a href="#&#x5176;&#x4ED6;"><b>1.42. </b>&#x5176;&#x4ED6;</a></li></ul></ul></div><a href="#cpp&#x57FA;&#x7840;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="cpp&#x57FA;&#x7840;"><a name="cpp&#x57FA;&#x7840;" class="anchor-navigation-ex-anchor" href="#cpp&#x57FA;&#x7840;"><i class="fa fa-link" aria-hidden="true"></i></a>1. cpp&#x57FA;&#x7840;</h1>
<p>C++&#x662F;&#x9762;&#x5411;&#x5BF9;&#x8C61;&#x7684;&#x8BED;&#x8A00;&#x3002; &#x662F;C&#x7684;&#x8D85;&#x96C6;&#xFF0C;&#x517C;&#x5BB9;&#x5927;&#x90E8;&#x5206;C&#x7684;&#x8BED;&#x6CD5;&#x7ED3;&#x6784; &#x3002;</p>
<h2 id="&#x6570;&#x636E;&#x7C7B;&#x578B;"><a name="&#x6570;&#x636E;&#x7C7B;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x636E;&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. &#x6570;&#x636E;&#x7C7B;&#x578B;</h2>
<table>
<thead>
<tr>
<th>&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;</th>
<th>&#x5B57;&#x8282;</th>
<th>&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td>char</td>
<td>1</td>
<td></td>
</tr>
<tr>
<td>unsigned char</td>
<td>1</td>
<td></td>
</tr>
<tr>
<td>signed  char</td>
<td>1</td>
<td></td>
</tr>
<tr>
<td>int</td>
<td>4</td>
<td></td>
</tr>
<tr>
<td>unsigned int</td>
<td>4</td>
<td></td>
</tr>
<tr>
<td>signed int</td>
<td>4</td>
<td></td>
</tr>
<tr>
<td>short int</td>
<td>2</td>
<td></td>
</tr>
<tr>
<td>unsigned short int</td>
<td>2</td>
<td></td>
</tr>
<tr>
<td>signed short int</td>
<td>2</td>
<td></td>
</tr>
<tr>
<td>long int</td>
<td>8</td>
<td></td>
</tr>
<tr>
<td>signed long int</td>
<td>8</td>
<td></td>
</tr>
<tr>
<td>unsigned long int</td>
<td>8</td>
<td></td>
</tr>
<tr>
<td>float</td>
<td>4</td>
<td></td>
</tr>
<tr>
<td>double</td>
<td>8</td>
<td></td>
</tr>
<tr>
<td>long double</td>
<td>16</td>
<td></td>
</tr>
<tr>
<td>wchar_t</td>
<td>2 &#x6216; 4</td>
<td>&#x5BBD;&#x5B57;&#x7B26;&#x578B;</td>
</tr>
</tbody>
</table>
<h2 id="&#x5173;&#x952E;&#x5B57;"><a name="&#x5173;&#x952E;&#x5B57;" class="anchor-navigation-ex-anchor" href="#&#x5173;&#x952E;&#x5B57;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2. &#x5173;&#x952E;&#x5B57;</h2>
<table>
<thead>
<tr>
<th>&#x5173;&#x952E;&#x5B57;</th>
<th>&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td>auto</td>
<td>&#x81EA;&#x52A8;&#x5B58;&#x50A8;&#x53D8;&#x91CF;&#x7684;&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x7533;&#x660E;&#x4E00;&#x5757;&#x4E34;&#x65F6;&#x7684;&#x53D8;&#x91CF;&#x5185;&#x5B58;&#x3002;auto&#x4E0D;&#x5199;&#x5219;&#x9690;&#x542B;&#x81EA;&#x52A8;&#x53D8;&#x91CF; &#x3002;auto int a &#x548C; int a&#x6548;&#x679C;&#x4E00;&#x6837;&#x3002;&#x6216;&#x8005; auto * result =xx ; &#x5F53;xx&#x7C7B;&#x578B;&#x6682;&#x65F6;&#x65E0;&#x6CD5;&#x786E;&#x5B9A;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x5148;&#x8868;&#x793A;&#x4E3A;auto&#x7C7B;&#x578B;&#x3002;&#x8BA9;&#x7F16;&#x8BD1;&#x5668;&#x6839;&#x636E;&#x8868;&#x8FBE;&#x5F0F;&#x81EA;&#x52A8;&#x63A8;&#x65AD;&#x53D8;&#x91CF;&#x7684;&#x7C7B;&#x578B;&#x3002;</td>
</tr>
<tr>
<td>decltype</td>
<td></td>
</tr>
<tr>
<td>const</td>
<td>&#x5B9A;&#x4E49;&#x6709;&#x7C7B;&#x578B;&#x7684;&#x5E38;&#x91CF;</td>
</tr>
<tr>
<td>define</td>
<td>&#x5B9A;&#x4E49;&#x6CA1;&#x6709;&#x7C7B;&#x578B;&#x7684;&#x5E38;&#x91CF;</td>
</tr>
<tr>
<td>cin</td>
<td>&#x952E;&#x76D8;&#x8F93;&#x5165;</td>
</tr>
<tr>
<td>cout</td>
<td></td>
</tr>
<tr>
<td>cerr</td>
<td></td>
</tr>
<tr>
<td>clog</td>
<td></td>
</tr>
<tr>
<td>stringstream</td>
<td>&#x63D0;&#x4F9B;&#x76F8;&#x5173;&#x7684;&#x8F6C;&#x6362;&#x548C;&#x683C;&#x5F0F;&#x5316;</td>
</tr>
<tr>
<td>inline</td>
<td>&#x4E3A;&#x4E86;&#x63D0;&#x9AD8;&#x51FD;&#x6570;&#x7684;&#x6267;&#x884C;&#x6548;&#x7387;</td>
</tr>
<tr>
<td>operator</td>
<td>&#x8FD0;&#x7B97;&#x7B26;&#x91CD;&#x8F7D;</td>
</tr>
<tr>
<td>friend</td>
<td>&#x53CB;&#x5143;</td>
</tr>
</tbody>
</table>
<pre><code class="lang-text">explicit  // &#x4FEE;&#x9970;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x7684;&#x7C7B;&#x6784;&#x9020;&#x51FD;&#x6570;, &#x5B83;&#x7684;&#x4F5C;&#x7528;&#x662F;&#x8868;&#x660E;&#x8BE5;&#x6784;&#x9020;&#x51FD;&#x6570;&#x662F;&#x663E;&#x793A;&#x7684;
implicit  // &#x4FEE;&#x9970;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x7684;&#x7C7B;&#x6784;&#x9020;&#x51FD;&#x6570;, &#x5B83;&#x7684;&#x4F5C;&#x7528;&#x662F;&#x8868;&#x660E;&#x8BE5;&#x6784;&#x9020;&#x51FD;&#x6570;&#x662F;&#x9690;&#x5F0F;&#x7684;
volatile  // &#x7C7B;&#x578B;&#x4FEE;&#x9970;&#x7B26;&#xFF0C;&#x8868;&#x793A;&#x53EF;&#x4EE5;&#x88AB;&#x67D0;&#x4E9B;&#x7F16;&#x8BD1;&#x5668;&#x672A;&#x77E5;&#x7684;&#x56E0;&#x7D20;&#x66F4;&#x6539;&#x3002;
</code></pre>
<h2 id="&#x7BAD;&#x5934;-----&#x548C;--&#x70B9;&#x53F7;--&#x64CD;&#x4F5C;&#x7B26;"><a name="&#x7BAD;&#x5934;-----&#x548C;--&#x70B9;&#x53F7;--&#x64CD;&#x4F5C;&#x7B26;" class="anchor-navigation-ex-anchor" href="#&#x7BAD;&#x5934;-----&#x548C;--&#x70B9;&#x53F7;--&#x64CD;&#x4F5C;&#x7B26;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3. &#x201C;&#x7BAD;&#x5934; -&gt; &#x201D;  &#x548C;&#x201C;  &#x70B9;&#x53F7; . &#x201D;&#x64CD;&#x4F5C;&#x7B26;</h2>
<pre><code class="lang-xml">&#x7BAD;&#x5934;&#xFF08;-&gt;&#xFF09;&#xFF1A;&#x5DE6;&#x8FB9;&#x5FC5;&#x987B;&#x4E3A;&#x6307;&#x9488;&#xFF1B;
&#x70B9;&#x53F7;&#xFF08;.&#xFF09;&#xFF1A;&#x5DE6;&#x8FB9;&#x5FC5;&#x987B;&#x4E3A;&#x5B9E;&#x4F53;&#x3002;
</code></pre>
<h2 id="&#x524D;&#x7F00;-&#x3001;-&#x540E;&#x7F00;"><a name="&#x524D;&#x7F00;-&#x3001;-&#x540E;&#x7F00;" class="anchor-navigation-ex-anchor" href="#&#x524D;&#x7F00;-&#x3001;-&#x540E;&#x7F00;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4. &#x524D;&#x7F00; &#x3001; &#x540E;&#x7F00;</h2>
<pre><code class="lang-xml">0x&#x6216;0X&#x8868;&#x793A;&#x5341;&#x516D;&#x8FDB;&#x5236;&#xFF0C;&#x4E0D;&#x5E26;&#x524D;&#x7F00;&#x5219;&#x9ED8;&#x8BA4;&#x8868;&#x793A;&#x5341;&#x8FDB;&#x5236;&#x3002;
&#x6574;&#x6570;&#x5E38;&#x91CF;&#x4E5F;&#x53EF;&#x4EE5;&#x5E26;&#x4E00;&#x4E2A;&#x540E;&#x7F00;&#xFF0C;&#x540E;&#x7F00;&#x662F;U&#x548C;L&#x7684;&#x7EC4;&#x5408;&#xFF0C;U&#x8868;&#x793A;unsigned&#xFF0C;L&#x8868;&#x793A;long&#x3002;
30ul       // &#x65E0;&#x7B26;&#x53F7;&#x957F;&#x6574;&#x6570;
</code></pre>
<h2 id="&#x9884;&#x5904;&#x7406;"><a name="&#x9884;&#x5904;&#x7406;" class="anchor-navigation-ex-anchor" href="#&#x9884;&#x5904;&#x7406;"><i class="fa fa-link" aria-hidden="true"></i></a>1.5. &#x9884;&#x5904;&#x7406;</h2>
<p>&#x6240;&#x6709;&#x7684;&#x9884;&#x5904;&#x7406;&#x5668;&#x6307;&#x4EE4;&#x90FD;&#x662F;&#x4EE5;&#x4E95;&#x53F7;&#xFF08;#&#xFF09;&#x5F00;&#x5934;&#xFF0C;&#x53EA;&#x6709;&#x7A7A;&#x683C;&#x5B57;&#x7B26;&#x53EF;&#x4EE5;&#x51FA;&#x73B0;&#x5728;&#x9884;&#x5904;&#x7406;&#x6307;&#x4EE4;&#x4E4B;&#x524D;&#x3002;&#x9884;&#x5904;&#x7406;&#x6307;&#x4EE4;&#x4E0D;&#x662F; C++ &#x8BED;&#x53E5;&#xFF0C;&#x6240;&#x4EE5;&#x5B83;&#x4EEC;&#x4E0D;&#x4F1A;&#x4EE5;&#x5206;&#x53F7;&#xFF08;;&#xFF09;&#x7ED3;&#x5C3E;&#x3002; <br> 
&#x9884;&#x5904;&#x7406;&#x6307;&#x4EE4;&#x7528;&#x4E8E;&#x521B;&#x5EFA;&#x7B26;&#x53F7;&#x5E38;&#x91CF;&#x3002;&#x8BE5;&#x7B26;&#x53F7;&#x5E38;&#x91CF;&#x901A;&#x5E38;&#x79F0;&#x4E3A;&#x5B8F;&#x3002;</p>
<pre><code class="lang-xml">#define PI 3.14159
#define MIN(a,b) (a&lt;b ? a : b)   //&#x5E26;&#x53C2;&#x6570;&#x7684;&#x5B8F;

#define   KEY_WIFI
#ifdef    KEY_WIFI // &#x5982;&#x679C;&#x5B9A;&#x4E49;&#x4E86;KEY_WIFI&#x6807;&#x8BB0; &#xFF0C;&#x53D6;&#x503C;&#x4E3A;100 &#x5426;&#x5219;&#x53D6;&#x503C; -20
#define   ARRAY_SIZE  100
#else
#define ARRAY_SIZE  -20
#endif

#ifndef KEY_WIFI // &#x5982;&#x679C;&#x6CA1;&#x6709;&#x5B9A;&#x4E49;&#x8FC7; xx &#xFF0C;&#x5C31;&#x5B9A;&#x4E49;
#define KEY_WIFI
#endif
#if 1  // &#x6761;&#x4EF6;&#x7F16;&#x8BD1;
#define TYPE  &quot;VITUS&quot;
# else
# define TYPE &quot;FE15&quot;
#endif

cout &lt;&lt; &quot;&#x5927;&#x5C0F;=&quot; &lt;&lt; ARRAY_SIZE &lt;&lt; endl;// &#x4F7F;&#x7528;
cout &lt;&lt; &quot;&#x7C7B;&#x578B;=&quot; &lt;&lt; TYPE &lt;&lt; endl;
</code></pre>
<h2 id="&#x5E38;&#x91CF;"><a name="&#x5E38;&#x91CF;" class="anchor-navigation-ex-anchor" href="#&#x5E38;&#x91CF;"><i class="fa fa-link" aria-hidden="true"></i></a>1.6. &#x5E38;&#x91CF;</h2>
<pre><code class="lang-xml">&#x53EF;&#x4EE5;&#x7528; define &#x3001;const&#x5B9A;&#x4E49;&#x5E38;&#x91CF;
#define LENGTH 10  
const int  LENGTH = 10;
</code></pre>
<h2 id="&#x53D8;&#x91CF;&#x58F0;&#x660E;-&#x3001;&#x53D8;&#x91CF;&#x5B9A;&#x4E49;"><a name="&#x53D8;&#x91CF;&#x58F0;&#x660E;-&#x3001;&#x53D8;&#x91CF;&#x5B9A;&#x4E49;" class="anchor-navigation-ex-anchor" href="#&#x53D8;&#x91CF;&#x58F0;&#x660E;-&#x3001;&#x53D8;&#x91CF;&#x5B9A;&#x4E49;"><i class="fa fa-link" aria-hidden="true"></i></a>1.7. &#x53D8;&#x91CF;&#x58F0;&#x660E; &#x3001;&#x53D8;&#x91CF;&#x5B9A;&#x4E49;</h2>
<p>&#x58F0;&#x660E;&#x4E0D;&#x4F1A;&#x5206;&#x914D;&#x5B58;&#x50A8;&#x7A7A;&#x95F4;&#xFF0C;&#x53EA;&#x6709;&#x5B9A;&#x4E49;&#x65F6;&#x624D;&#x4F1A;&#x5206;&#x914D;&#x5B58;&#x50A8;&#x7A7A;&#x95F4;&#x3002; &#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5173;&#x952E;&#x5B57;extern&#x5728;&#x4EFB;&#x4F55;&#x5730;&#x65B9;&#xFF08;&#x591A;&#x6B21;&#xFF09;&#x58F0;&#x660E;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#x3002; &#x4F46;&#x53D8;&#x91CF;&#x53EA;&#x80FD;&#x5728;&#x67D0;&#x4E2A;&#x6587;&#x4EF6;&#x3001;&#x51FD;&#x6570;&#x6216;&#x4EE3;&#x7801;&#x5757;&#x4E2D;&#x88AB;&#x5B9A;&#x4E49;&#x4E00;&#x6B21;&#x3002;</p>
<pre><code class="lang-xml">#include <span class="hljs-tag">&lt;<span class="hljs-name">iostream</span>&gt;</span>
extern int a;// &#x53D8;&#x91CF;&#x58F0;&#x660E;
int main ()
{
  int a, b; // &#x53D8;&#x91CF;&#x5B9A;&#x4E49;
  a = 10;// &#x5B9E;&#x9645;&#x521D;&#x59CB;&#x5316;
  return 0;
}
</code></pre>
<h3 id="&#x53D8;&#x91CF;&#x521D;&#x59CB;&#x5316;"><a name="&#x53D8;&#x91CF;&#x521D;&#x59CB;&#x5316;" class="anchor-navigation-ex-anchor" href="#&#x53D8;&#x91CF;&#x521D;&#x59CB;&#x5316;"><i class="fa fa-link" aria-hidden="true"></i></a>1.7.1. &#x53D8;&#x91CF;&#x521D;&#x59CB;&#x5316;</h3>
<pre><code class="lang-xml">&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x88AB;&#x5B9A;&#x4E49;&#x65F6;&#xFF0C;&#x7CFB;&#x7EDF;&#x4E0D;&#x4F1A;&#x5BF9;&#x5176;&#x521D;&#x59CB;&#x5316;&#xFF0C;&#x5FC5;&#x987B;&#x624B;&#x52A8;&#x8D4B;&#x503C;&#x521D;&#x59CB;&#x5316;&#x3002;
&#x5B9A;&#x4E49;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x65F6;&#xFF0C;&#x7CFB;&#x7EDF;&#x4F1A;&#x81EA;&#x52A8;&#x521D;&#x59CB;&#x5316;&#x5B83;&#x3002;
</code></pre>
<h2 id="&#x5DE6;&#x503C;&#x3001;&#x53F3;&#x503C;"><a name="&#x5DE6;&#x503C;&#x3001;&#x53F3;&#x503C;" class="anchor-navigation-ex-anchor" href="#&#x5DE6;&#x503C;&#x3001;&#x53F3;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8. &#x5DE6;&#x503C;&#x3001;&#x53F3;&#x503C;</h2>
<pre><code class="lang-xml">&#x6307;&#x5411;&#x5185;&#x5B58;&#x4F4D;&#x7F6E;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x88AB;&#x79F0;&#x4E3A;&#x5DE6;&#x503C;&#x8868;&#x8FBE;&#x5F0F;&#x3002;
&#x53F3;&#x503C;&#x6307;&#x7684;&#x662F;&#x5B58;&#x50A8;&#x5728;&#x5185;&#x5B58;&#x4E2D;&#x67D0;&#x4E9B;&#x5730;&#x5740;&#x7684;&#x6570;&#x503C;&#x3002;
int g = 20;//ok
10 = 20; // wrong
</code></pre>
<h2 id="&#x5F02;&#x5E38;"><a name="&#x5F02;&#x5E38;" class="anchor-navigation-ex-anchor" href="#&#x5F02;&#x5E38;"><i class="fa fa-link" aria-hidden="true"></i></a>1.9. &#x5F02;&#x5E38;</h2>
<pre><code class="lang-c++"><span class="hljs-keyword">try</span> {
    <span class="hljs-keyword">throw</span> <span class="hljs-string">&quot;&#x53D1;&#x751F;&#x5F02;&#x5E38;&#xFF01;&quot;</span>;
}
<span class="hljs-keyword">catch</span>  ( <span class="hljs-keyword">char</span> * msg)
{
    <span class="hljs-built_in">cout</span> &lt;&lt;  msg &lt;&lt; <span class="hljs-built_in">endl</span>;
}
</code></pre>
<h2 id="&#x53CB;&#x5143;&#x51FD;&#x6570;-&#x3001;&#x53CB;&#x5143;&#x7C7B;"><a name="&#x53CB;&#x5143;&#x51FD;&#x6570;-&#x3001;&#x53CB;&#x5143;&#x7C7B;" class="anchor-navigation-ex-anchor" href="#&#x53CB;&#x5143;&#x51FD;&#x6570;-&#x3001;&#x53CB;&#x5143;&#x7C7B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.10. &#x53CB;&#x5143;&#x51FD;&#x6570; &#x3001;&#x53CB;&#x5143;&#x7C7B;</h2>
<pre><code class="lang-c++">&#x91C7;&#x7528;&#x7C7B;&#x7684;&#x673A;&#x5236;&#x540E;&#x5B9E;&#x73B0;&#x4E86;&#x6570;&#x636E;&#x7684;&#x9690;&#x85CF;&#x4E0E;&#x5C01;&#x88C5; &#x3002;
&#x4F46;&#x662F;&#xFF0C;&#x5176;&#x4ED6;&#x7C7B;&#x7684;&#x67D0;&#x4E2A;&#x51FD;&#x6570;&#x9700;&#x8981;&#x9891;&#x7E41;&#x5730;&#x8BBF;&#x95EE;&#x7C7B;&#x7684;&#x6570;&#x636E;&#x6210;&#x5458;&#xFF0C;
&#x8FD9;&#x65F6;&#x53EF;&#x4EE5;&#x5C06;&#x8FD9;&#x4E9B;&#x51FD;&#x6570;&#x5B9A;&#x4E49;&#x4E3A;&#x8BE5;&#x51FD;&#x6570;&#x7684;&#x53CB;&#x5143;&#x51FD;&#x6570;&#x3002;
&#x53CB;&#x5143;&#x7684;&#x4F5C;&#x7528;&#x662F;&#x63D0;&#x9AD8;&#x4E86;&#x7A0B;&#x5E8F;&#x7684;&#x8FD0;&#x884C;&#x6548;&#x7387;&#xFF08;&#x5373;&#x51CF;&#x5C11;&#x4E86;&#x7C7B;&#x578B;&#x68C0;&#x67E5;&#x548C;&#x5B89;&#x5168;&#x6027;&#x68C0;&#x67E5;&#x7B49;&#x90FD;&#x9700;&#x8981;&#x65F6;&#x95F4;&#x5F00;&#x9500;&#xFF09;&#xFF0C;
&#x4F46;&#x5B83;&#x7834;&#x574F;&#x4E86;&#x7C7B;&#x7684;&#x5C01;&#x88C5;&#x6027;&#x548C;&#x9690;&#x85CF;&#x6027;&#xFF0C;&#x4F7F;&#x5F97;&#x975E;&#x6210;&#x5458;&#x51FD;&#x6570;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;&#x7C7B;&#x7684;&#x79C1;&#x6709;&#x6210;&#x5458;&#x3002;
</code></pre>
<h2 id="&#x7EE7;&#x627F;"><a name="&#x7EE7;&#x627F;" class="anchor-navigation-ex-anchor" href="#&#x7EE7;&#x627F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.11. &#x7EE7;&#x627F;</h2>
<pre><code class="lang-xml">c++ &#x652F;&#x6301;&#x591A;&#x7EE7;&#x627F;
&#x7EE7;&#x627F;&#x65B9;&#x5F0F;&#x53EF;&#x9009;&#x8303;&#x56F4; public(&#x5E38;&#x7528;)&#x3001;protected &#x3001; private(&#x9ED8;&#x8BA4;)  
class Rectangle: public Shape ,<span class="hljs-tag">&lt;<span class="hljs-name">&#x7EE7;&#x627F;&#x65B9;&#x5F0F;2</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">&#x57FA;&#x7C7B;&#x540D;2</span>&gt;</span>   
{
...
}
</code></pre>
<h2 id="&#x51FD;&#x6570;&#x91CD;&#x8F7D;"><a name="&#x51FD;&#x6570;&#x91CD;&#x8F7D;" class="anchor-navigation-ex-anchor" href="#&#x51FD;&#x6570;&#x91CD;&#x8F7D;"><i class="fa fa-link" aria-hidden="true"></i></a>1.12. &#x51FD;&#x6570;&#x91CD;&#x8F7D;</h2>
<pre><code class="lang-xml">void print(int i) 
{...}

void print(double f) 
{...}
</code></pre>
<h2 id="&#x64CD;&#x4F5C;&#x7B26;&#x91CD;&#x8F7D;-&#x3001;-&#x8FD0;&#x7B97;&#x7B26;&#x91CD;&#x8F7D;"><a name="&#x64CD;&#x4F5C;&#x7B26;&#x91CD;&#x8F7D;-&#x3001;-&#x8FD0;&#x7B97;&#x7B26;&#x91CD;&#x8F7D;" class="anchor-navigation-ex-anchor" href="#&#x64CD;&#x4F5C;&#x7B26;&#x91CD;&#x8F7D;-&#x3001;-&#x8FD0;&#x7B97;&#x7B26;&#x91CD;&#x8F7D;"><i class="fa fa-link" aria-hidden="true"></i></a>1.13. &#x64CD;&#x4F5C;&#x7B26;&#x91CD;&#x8F7D; &#x3001; &#x8FD0;&#x7B97;&#x7B26;&#x91CD;&#x8F7D;</h2>
<table>
<thead>
<tr>
<th>&#x4E0D;&#x80FD;&#x88AB;&#x91CD;&#x8F7D;&#x7684;&#x64CD;&#x4F5C;&#x7B26;</th>
<th>&#x8BF4;&#x660E;</th>
<th>&#x5176;&#x4ED6;</th>
</tr>
</thead>
<tbody>
<tr>
<td>&#x6210;&#x5458;&#x8BBF;&#x95EE;&#x8FD0;&#x7B97;&#x7B26;</td>
<td>.</td>
</tr>
<tr>
<td>&#x6210;&#x5458;&#x6307;&#x9488;&#x8BBF;&#x95EE;&#x8FD0;&#x7B97;&#x7B26;</td>
<td>.*</td>
</tr>
<tr>
<td>&#x57DF;&#x8FD0;&#x7B97;&#x7B26;</td>
<td>::</td>
</tr>
<tr>
<td>&#x957F;&#x5EA6;&#x8FD0;&#x7B97;&#x7B26;</td>
<td>sizeof</td>
<td>&#x53D8;&#x91CF;&#x7684;&#x5927;&#x5C0F;&#x4F1A;&#x6839;&#x636E;&#x7F16;&#x8BD1;&#x5668;&#x548C;&#x6240;&#x4F7F;&#x7528;&#x7684;&#x7535;&#x8111;&#x800C;&#x6709;&#x6240;&#x4E0D;&#x540C;&#x3002;  </td>
</tr>
<tr>
<td>&#x6761;&#x4EF6;&#x8FD0;&#x7B97;&#x7B26;</td>
<td>?:</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>&#x53EF;&#x4EE5;&#x91CD;&#x8F7D;&#x7684;&#x64CD;&#x4F5C;&#x7B26;</th>
<th>&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td>&#x53CC;&#x76EE;&#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x7B26;</td>
<td>+ (&#x52A0;)&#xFF0C;-(&#x51CF;)&#xFF0C;*(&#x4E58;)&#xFF0C;/(&#x9664;)&#xFF0C;% (&#x53D6;&#x6A21;)</td>
</tr>
<tr>
<td>&#x5173;&#x7CFB;&#x8FD0;&#x7B97;&#x7B26;</td>
<td>==(&#x7B49;&#x4E8E;)&#xFF0C;!= (&#x4E0D;&#x7B49;&#x4E8E;)&#xFF0C;&lt; (&#x5C0F;&#x4E8E;)&#xFF0C;&gt; (&#x5927;&#x4E8E;&gt;&#xFF0C;&lt;=(&#x5C0F;&#x4E8E;&#x7B49;&#x4E8E;)&#xFF0C;&gt;=(&#x5927;&#x4E8E;&#x7B49;&#x4E8E;)</td>
</tr>
<tr>
<td>&#x903B;&#x8F91;&#x8FD0;&#x7B97;&#x7B26;</td>
<td>|| (&#x903B;&#x8F91;&#x6216;)&#xFF0C;&amp;&amp;(&#x903B;&#x8F91;&#x4E0E;)&#xFF0C;!(&#x903B;&#x8F91;&#x975E;)</td>
</tr>
<tr>
<td>&#x5355;&#x76EE;&#x8FD0;&#x7B97;&#x7B26;</td>
<td>+ (&#x6B63;)&#xFF0C;-(&#x8D1F;)&#xFF0C;*(&#x6307;&#x9488;)&#xFF0C;&amp;(&#x53D6;&#x5730;&#x5740;)</td>
</tr>
<tr>
<td>&#x81EA;&#x589E;&#x81EA;&#x51CF;&#x8FD0;&#x7B97;&#x7B26;</td>
<td>++(&#x81EA;&#x589E;)&#xFF0C;--(&#x81EA;&#x51CF;)</td>
</tr>
<tr>
<td>&#x4F4D;&#x8FD0;&#x7B97;&#x7B26;</td>
<td>| (&#x6309;&#x4F4D;&#x6216;)&#xFF0C;&amp; (&#x6309;&#x4F4D;&#x4E0E;)&#xFF0C;~(&#x6309;&#x4F4D;&#x53D6;&#x53CD;)&#xFF0C;^(&#x6309;&#x4F4D;&#x5F02;&#x6216;),&#xFF0C;&lt;&lt; (&#x5DE6;&#x79FB;)&#xFF0C;&gt;&gt;(&#x53F3;&#x79FB;)</td>
</tr>
<tr>
<td>&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;</td>
<td>=, +=, -=, *=, /= , % = , &amp;=, |=, ^=, &lt;&lt;=, &gt;&gt;=</td>
</tr>
<tr>
<td>&#x7A7A;&#x95F4;&#x7533;&#x8BF7;&#x4E0E;&#x91CA;&#x653E;</td>
<td>new, delete, new[ ] , delete[]</td>
</tr>
<tr>
<td>&#x5176;&#x4ED6;&#x8FD0;&#x7B97;&#x7B26;</td>
<td>()(&#x51FD;&#x6570;&#x8C03;&#x7528;)&#xFF0C;-&gt;(&#x6210;&#x5458;&#x8BBF;&#x95EE;)&#xFF0C;,(&#x9017;&#x53F7;)&#xFF0C;<a href="&#x4E0B;&#x6807;"></a></td>
</tr>
</tbody>
</table>
<pre><code class="lang-xml">&#x8FD0;&#x7B97;&#x7B26;&#x91CD;&#x8F7D;&#x662F;&#x4E3A;&#x4E86;&#x66F4;&#x65B9;&#x4FBF;&#x5730;&#x64CD;&#x4F5C;&#x7C7B;&#x7C7B;&#x578B;&#x6570;&#x636E;&#x800C;&#x8BBE;&#x8BA1;&#x7684;&#x3002;
&#x91CD;&#x8F7D;&#x7684;&#x8FD0;&#x7B97;&#x7B26;&#x53C2;&#x6570;&#x4E2D;&#x81F3;&#x5C11;&#x8981;&#x6709;&#x4E00;&#x4E2A;&#x7C7B;&#x7C7B;&#x578B;&#x6216;&#x679A;&#x4E3E;&#x7C7B;&#x578B;.&#x5426;&#x5219;&#x7F16;&#x8BD1;&#x4E0D;&#x8FC7;&#x3002;
public:
    int whitePeople;
    int blackPeoople;

    void display()
    { ...}


// &#x91CD;&#x8F7D;&#x8FD0;&#x7B97;&#x7B26; +
Group   operator+  (Group &amp; g1 , Group &amp;g2)
{
    Group sum;
    sum.whitePeople = g1.whitePeople + g2.whitePeople;
    sum.blackPeoople = g1.blackPeoople + g2.blackPeoople;
    return sum ;
}

Group g1  ,g2  , g3;
g1.whitePeople = 10;
g1.blackPeoople = 10;
g2.whitePeople = 100;
g2.blackPeoople = 200;
g3 = g1 + g2;
g3.display();
</code></pre>
<h2 id="&#x6307;&#x9488;"><a name="&#x6307;&#x9488;" class="anchor-navigation-ex-anchor" href="#&#x6307;&#x9488;"><i class="fa fa-link" aria-hidden="true"></i></a>1.14. &#x6307;&#x9488;</h2>
<pre><code class="lang-c++"><span class="hljs-keyword">int</span> *p ; <span class="hljs-keyword">int</span>* p;  <span class="hljs-comment">// p&#x662F;&#x6307;&#x5411;&#x4E00;&#x4E2A;&#x6574;&#x6570;&#x7C7B;&#x578B;&#x7684;&#x6307;&#x9488;</span>
x=*p<span class="hljs-comment">// &#x628A;&#x6307;&#x9488;p&#x6307;&#x5411;&#x7684;&#x503C;&#x8D4B;&#x503C;&#x7ED9;x</span>
p=&amp;x<span class="hljs-comment">// &#x628A;x&#x7684;&#x5730;&#x5740;&#x8D4B;&#x7ED9;p&#xFF08;&#x6307;&#x9488;&#xFF09; &#x3002;&#x4EC5;&#x4EC5;&#x901A;&#x8FC7;&#x6307;&#x9488;&#x65E0;&#x6CD5;&#x77E5;&#x9053;&#x6307;&#x5411;&#x6570;&#x7EC4;&#x7684;&#x5927;&#x5C0F;</span>
</code></pre>
<h2 id="&#x5F15;&#x7528;"><a name="&#x5F15;&#x7528;" class="anchor-navigation-ex-anchor" href="#&#x5F15;&#x7528;"><i class="fa fa-link" aria-hidden="true"></i></a>1.15. &#x5F15;&#x7528;</h2>
<pre><code class="lang-c++">&#x5F15;&#x7528;&#x5C31;&#x662F;&#x67D0;&#x4E00;&#x53D8;&#x91CF;&#x7684;&#x4E00;&#x4E2A;&#x522B;&#x540D;&#xFF0C;&#x5BF9;&#x5F15;&#x7528;&#x7684;&#x64CD;&#x4F5C;&#x4E0E;&#x5BF9;&#x53D8;&#x91CF;&#x76F4;&#x63A5;&#x64CD;&#x4F5C;&#x5B8C;&#x5168;&#x4E00;&#x6837; &#x3002;
&#x5BF9;&#x5F15;&#x7528;&#x6C42;&#x5730;&#x5740;&#xFF0C;&#x5C31;&#x662F;&#x5BF9;&#x76EE;&#x6807;&#x53D8;&#x91CF;&#x6C42;&#x5730;&#x5740;&#x3002;
<span class="hljs-keyword">int</span> a;
<span class="hljs-keyword">int</span> &amp;ra=a; <span class="hljs-comment">//&amp; &#x8BFB;&#x4F5C;&#x5F15;&#x7528;&#x3002;</span>

<span class="hljs-comment">//&#x6B64;&#x5904;&#x51FD;&#x6570;&#x7684;&#x5F62;&#x53C2;p1, p2&#x90FD;&#x662F;&#x5F15;&#x7528;</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">swap</span><span class="hljs-params">(<span class="hljs-keyword">int</span> &amp;p1, <span class="hljs-keyword">int</span> &amp;p2)</span>
</span>{
  ...
}
</code></pre>
<h3 id="&#x6307;&#x9488;&#x4E0E;&#x5F15;&#x7528;&#x7684;&#x533A;&#x522B;"><a name="&#x6307;&#x9488;&#x4E0E;&#x5F15;&#x7528;&#x7684;&#x533A;&#x522B;" class="anchor-navigation-ex-anchor" href="#&#x6307;&#x9488;&#x4E0E;&#x5F15;&#x7528;&#x7684;&#x533A;&#x522B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.15.1. &#x6307;&#x9488;&#x4E0E;&#x5F15;&#x7528;&#x7684;&#x533A;&#x522B;</h3>
<pre><code class="lang-xml">1&#x3001;&#x4E0D;&#x5B58;&#x5728;&#x7A7A;&#x5F15;&#x7528;&#x3002;&#x5F15;&#x7528;&#x5FC5;&#x987B;&#x8FDE;&#x63A5;&#x5230;&#x4E00;&#x5757;&#x5408;&#x6CD5;&#x7684;&#x5185;&#x5B58;&#x3002;
2&#x3001;&#x4E00;&#x65E6;&#x5F15;&#x7528;&#x88AB;&#x521D;&#x59CB;&#x5316;&#x4E3A;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x5C31;&#x4E0D;&#x80FD;&#x88AB;&#x6307;&#x5411;&#x5230;&#x53E6;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x3002;&#x6307;&#x9488;&#x53EF;&#x4EE5;&#x5728;&#x4EFB;&#x4F55;&#x65F6;&#x5019;&#x6307;&#x5411;&#x5230;&#x53E6;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x3002;
3&#x3001;&#x5F15;&#x7528;&#x5FC5;&#x987B;&#x5728;&#x521B;&#x5EFA;&#x65F6;&#x88AB;&#x521D;&#x59CB;&#x5316;&#x3002;&#x6307;&#x9488;&#x53EF;&#x4EE5;&#x5728;&#x4EFB;&#x4F55;&#x65F6;&#x95F4;&#x88AB;&#x521D;&#x59CB;&#x5316;&#x3002;
</code></pre>
<p><br></p>
<h2 id="&#x8F93;&#x5165;&#x8F93;&#x51FA;"><a name="&#x8F93;&#x5165;&#x8F93;&#x51FA;" class="anchor-navigation-ex-anchor" href="#&#x8F93;&#x5165;&#x8F93;&#x51FA;"><i class="fa fa-link" aria-hidden="true"></i></a>1.16. &#x8F93;&#x5165;&#x8F93;&#x51FA;</h2>
<pre><code class="lang-c++"><span class="hljs-keyword">int</span>  a = <span class="hljs-number">0</span>;
<span class="hljs-comment">// &#x8F93;&#x5165;&#x6570;&#x5B57;</span>
<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x4E00;&#x4E2A;&#x6570;&#x5B57; \n&quot;</span>;
<span class="hljs-built_in">cin</span> &gt;&gt; a;
<span class="hljs-built_in">cout</span> &lt;&lt;   a &lt;&lt; <span class="hljs-built_in">endl</span>;
<span class="hljs-comment">// &#x8F93;&#x5165;&#x5B57;&#x7B26;&#x4E32;(&#x4E0D;&#x80FD;&#x6709;&#x7A7A;&#x683C;)</span>
<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x4E00;&#x4E2A;&#x6CA1;&#x6709;&#x7A7A;&#x683C;&#x5B57;&#x7B26;&#x4E32; \n&quot;</span>;
<span class="hljs-built_in">string</span> mystr;
<span class="hljs-built_in">cin</span> &gt;&gt; mystr;
<span class="hljs-built_in">cout</span> &lt;&lt;   mystr &lt;&lt; <span class="hljs-built_in">endl</span>;
<span class="hljs-comment">// &#x8F93;&#x5165;&#x5B57;&#x7B26;&#x4E32;(&#x53EF;&#x4EE5;&#x6709;&#x7A7A;&#x683C;)</span>
<span class="hljs-built_in">string</span> mystr2;
<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x4E00;&#x4E2A;&#x6709;&#x7A7A;&#x683C;&#x5B57;&#x7B26;&#x4E32; \n&quot;</span>;
getline(<span class="hljs-built_in">cin</span>, mystr2);
<span class="hljs-built_in">cout</span> &lt;&lt; mystr2 &lt;&lt; <span class="hljs-built_in">endl</span>;
</code></pre>
<p><br></p>
<h2 id="&#x7C7B;&#x578B;&#x8F6C;&#x6362;"><a name="&#x7C7B;&#x578B;&#x8F6C;&#x6362;" class="anchor-navigation-ex-anchor" href="#&#x7C7B;&#x578B;&#x8F6C;&#x6362;"><i class="fa fa-link" aria-hidden="true"></i></a>1.17. &#x7C7B;&#x578B;&#x8F6C;&#x6362;</h2>
<pre><code class="lang-c++"><span class="hljs-built_in">string</span> mystr;
<span class="hljs-keyword">float</span> price = <span class="hljs-number">0</span>;
<span class="hljs-keyword">int</span> quantity = <span class="hljs-number">0</span>;

getline(<span class="hljs-built_in">cin</span>, mystr);
<span class="hljs-comment">// &#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x4E3A; int</span>
<span class="hljs-built_in">stringstream</span>(mystr) &gt;&gt; quantity;
<span class="hljs-comment">// &#x5B57;&#x7B26;&#x4E32;&#x8F6C;&#x4E3A; float</span>
getline(<span class="hljs-built_in">cin</span>, mystr);
<span class="hljs-built_in">stringstream</span>(mystr) &gt;&gt; price;
<span class="hljs-built_in">cout</span> &lt;&lt;   quantity  &lt;&lt;  <span class="hljs-string">&quot; &quot;</span>&lt;&lt; price  &lt;&lt;<span class="hljs-built_in">endl</span>;
</code></pre>
<pre><code class="lang-text">static_cast           //  &#x7C7B;&#x578B;&#x5F3A;&#x5236;&#x8F6C;&#x6362;&#xFF0C;&#x6548;&#x679C;&#x5C31;&#x76F8;&#x5F53;&#x4E8E;&#x52A0;&#x4E2A;&#x62EC;&#x53F7;:int a=(long)b; 
reinterpret_cast      //   &#x7C7B;&#x578B;&#x5F3A;&#x5236;&#x8F6C;&#x6362;&#xFF0C;&#x4E0E;static_cast &#x6709;&#x7EC6;&#x5FAE;&#x5DEE;&#x522B;&#x3002;
dynamic_pointer_cast  // 
dynamic_cast          //
</code></pre>
<h2 id="&#x4F20;&#x503C;&#x53C2;&#x6570;--&#x5F15;&#x7528;&#x53C2;&#x6570;"><a name="&#x4F20;&#x503C;&#x53C2;&#x6570;--&#x5F15;&#x7528;&#x53C2;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x4F20;&#x503C;&#x53C2;&#x6570;--&#x5F15;&#x7528;&#x53C2;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>1.18. &#x4F20;&#x503C;&#x53C2;&#x6570;  &#x5F15;&#x7528;&#x53C2;&#x6570;</h2>
<pre><code class="lang-c++"><span class="hljs-comment">// &#x4E0D;&#x4F1A;&#x6539;&#x53D8;&#x539F;&#x59CB;&#x5185;&#x5BB9;</span>
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">func1</span><span class="hljs-params">(<span class="hljs-keyword">int</span> valuea, <span class="hljs-keyword">int</span> value2)</span>
</span>{
    <span class="hljs-keyword">int</span> result = valuea + value2;
    valuea += <span class="hljs-number">10</span>;
    <span class="hljs-keyword">return</span> result;
}

<span class="hljs-comment">// &#x4F1A;&#x6539;&#x53D8;&#x6700;&#x539F;&#x59CB;&#x7684;&#x503C;&#x7684;&#x5185;&#x5BB9;</span>
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">func2</span><span class="hljs-params">(<span class="hljs-keyword">int</span>&amp; valuea, <span class="hljs-keyword">int</span>&amp; value2)</span>
</span>{
    <span class="hljs-keyword">int</span> result = valuea + value2;
    valuea += <span class="hljs-number">10</span>;
    <span class="hljs-keyword">return</span> result;
}
</code></pre>
<h2 id="&#x6A21;&#x677F;"><a name="&#x6A21;&#x677F;" class="anchor-navigation-ex-anchor" href="#&#x6A21;&#x677F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.19. &#x6A21;&#x677F;</h2>
<p>&#x6A21;&#x677F;&#x5C31;&#x662F;&#x5B9E;&#x73B0;&#x4EE3;&#x7801;&#x91CD;&#x7528;&#x673A;&#x5236;&#x7684;&#x4E00;&#x79CD;&#x5DE5;&#x5177;&#x3002;</p>
<h3 id="&#x51FD;&#x6570;&#x6A21;&#x677F;"><a name="&#x51FD;&#x6570;&#x6A21;&#x677F;" class="anchor-navigation-ex-anchor" href="#&#x51FD;&#x6570;&#x6A21;&#x677F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.19.1. &#x51FD;&#x6570;&#x6A21;&#x677F;</h3>
<p>&#x5BF9;&#x51FD;&#x6570;&#x6A21;&#x677F;&#x7684;&#x7406;&#x89E3;&#x53EF;&#x4EE5;&#x53C2;&#x8003;Java&#x7684;&#x6CDB;&#x578B;</p>
<pre><code class="lang-c++"><span class="hljs-keyword">template</span>&lt;<span class="hljs-keyword">typename</span> T&gt;
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">compare</span><span class="hljs-params">(<span class="hljs-keyword">const</span> T&amp; left, <span class="hljs-keyword">const</span> T&amp; right)</span>
</span>{
    <span class="hljs-keyword">return</span> left+ right ;
}
<span class="hljs-keyword">int</span> a = <span class="hljs-number">10</span>;
<span class="hljs-keyword">int</span> b = <span class="hljs-number">20</span>;
<span class="hljs-keyword">float</span> c = <span class="hljs-number">10.6</span>;
<span class="hljs-keyword">float</span> d = <span class="hljs-number">20.7</span>;
<span class="hljs-built_in">cout</span> &lt;&lt; compare(a ,b ) &lt;&lt; <span class="hljs-built_in">endl</span>;
<span class="hljs-built_in">cout</span> &lt;&lt; compare(c, d) &lt;&lt; <span class="hljs-built_in">endl</span>;
</code></pre>
<h3 id="&#x7C7B;&#x6A21;&#x677F;"><a name="&#x7C7B;&#x6A21;&#x677F;" class="anchor-navigation-ex-anchor" href="#&#x7C7B;&#x6A21;&#x677F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.19.2. &#x7C7B;&#x6A21;&#x677F;</h3>
<pre><code class="lang-xml">template <span class="hljs-tag">&lt; <span class="hljs-attr">class</span>&#x6216;&#x8005;&#x4E5F;&#x53EF;&#x4EE5;&#x7528;<span class="hljs-attr">typename</span> <span class="hljs-attr">T</span> &gt;</span>
class&#x7C7B;&#x540D;&#xFF5B;
&#xFF0F;&#xFF0F;&#x7C7B;&#x5B9A;&#x4E49;&#xFF0E;&#xFF0E;&#xFF0E;&#xFF0E;&#xFF0E;&#xFF0E;
&#xFF5D;;
</code></pre>
<h2 id="&#x547D;&#x540D;&#x7A7A;&#x95F4;"><a name="&#x547D;&#x540D;&#x7A7A;&#x95F4;" class="anchor-navigation-ex-anchor" href="#&#x547D;&#x540D;&#x7A7A;&#x95F4;"><i class="fa fa-link" aria-hidden="true"></i></a>1.20. &#x547D;&#x540D;&#x7A7A;&#x95F4;</h2>
<p>&#x547D;&#x540D;&#x7A7A;&#x95F4;&#x7528;&#x6765;&#x89E3;&#x51B3; &#x547D;&#x540D;&#x51B2;&#x7A81;&#x7684;&#x95EE;&#x9898;&#x3002;&#x672C;&#x8D28;&#x4E0A;&#xFF0C;&#x547D;&#x540D;&#x7A7A;&#x95F4;&#x5C31;&#x662F;&#x5B9A;&#x4E49;&#x4E86;&#x4E00;&#x4E2A;&#x8303;&#x56F4;&#x3002;</p>
<pre><code class="lang-c++"><span class="hljs-keyword">namespace</span> mSpaceA
{
    <span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">func</span><span class="hljs-params">( <span class="hljs-keyword">int</span> a  , <span class="hljs-keyword">int</span> b )</span>
    </span>{
        <span class="hljs-keyword">return</span>  a + b;
    }
}

<span class="hljs-keyword">namespace</span> mSpaceB
{
    <span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">func</span><span class="hljs-params">(<span class="hljs-keyword">int</span> a, <span class="hljs-keyword">int</span> b)</span>
    </span>{
        <span class="hljs-keyword">return</span> a*b;
    }
}

<span class="hljs-keyword">int</span> a = <span class="hljs-number">10</span>;
<span class="hljs-keyword">int</span> b = <span class="hljs-number">20</span>;
<span class="hljs-built_in">cout</span> &lt;&lt; mSpaceA::func(a , b) &lt;&lt; <span class="hljs-built_in">endl</span>;
<span class="hljs-built_in">cout</span> &lt;&lt; mSpaceB::func(a, b)  &lt;&lt; <span class="hljs-built_in">endl</span>;
</code></pre>
<h2 id="&#x6570;&#x7EC4;"><a name="&#x6570;&#x7EC4;" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x7EC4;"><i class="fa fa-link" aria-hidden="true"></i></a>1.21. &#x6570;&#x7EC4;</h2>
<pre><code class="lang-c++"><span class="hljs-keyword">int</span> mArray []  = { <span class="hljs-number">5</span>, <span class="hljs-number">10</span>, <span class="hljs-number">15</span> };
<span class="hljs-comment">// &#x957F;&#x5EA6;</span>
<span class="hljs-built_in">cout</span> &lt;&lt;  end( mArray ) - begin(mArray) &lt;&lt; <span class="hljs-built_in">endl</span>;
</code></pre>
<h2 id="&#x5B57;&#x7B26;&#x4E32;"><a name="&#x5B57;&#x7B26;&#x4E32;" class="anchor-navigation-ex-anchor" href="#&#x5B57;&#x7B26;&#x4E32;"><i class="fa fa-link" aria-hidden="true"></i></a>1.22. &#x5B57;&#x7B26;&#x4E32;</h2>
<pre><code class="lang-c++"><span class="hljs-comment">// string &#x98CE;&#x683C;&#x7684;&#x5B57;&#x7B26;&#x4E32;</span>
<span class="hljs-built_in">string</span> str1 = <span class="hljs-string">&quot;aaa&quot;</span>;
<span class="hljs-built_in">string</span> str2 = <span class="hljs-string">&quot;bbb&quot;</span>;
str1 += str2;
<span class="hljs-built_in">cout</span> &lt;&lt; str1 &lt;&lt; <span class="hljs-built_in">endl</span>;

<span class="hljs-comment">// c &#x98CE;&#x683C;&#x7684;&#x5B57;&#x7B26;&#x4E32;</span>
<span class="hljs-keyword">char</span> str3[] = <span class="hljs-string">&quot;hello&quot;</span>;
<span class="hljs-keyword">char</span> str4[] = <span class="hljs-string">&quot;world&quot;</span>;
<span class="hljs-built_in">strcat</span>(str3, str4);
<span class="hljs-built_in">cout</span> &lt;&lt; str3 &lt;&lt; <span class="hljs-built_in">endl</span>;
</code></pre>
<h2 id="&#x52A8;&#x6001;&#x5185;&#x5B58;"><a name="&#x52A8;&#x6001;&#x5185;&#x5B58;" class="anchor-navigation-ex-anchor" href="#&#x52A8;&#x6001;&#x5185;&#x5B58;"><i class="fa fa-link" aria-hidden="true"></i></a>1.23. &#x52A8;&#x6001;&#x5185;&#x5B58;</h2>
<pre><code class="lang-c++"><span class="hljs-comment">// &#x5F00;&#x8F9F;&#x7A7A;&#x95F4;</span>
<span class="hljs-keyword">int</span>* intArray = <span class="hljs-keyword">new</span> <span class="hljs-keyword">int</span>[<span class="hljs-number">5</span>];
intArray[<span class="hljs-number">3</span>] = <span class="hljs-number">100</span>;

<span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i=<span class="hljs-number">0</span>; i&lt; <span class="hljs-number">5</span> ;i++)
{
  <span class="hljs-built_in">cout</span> &lt;&lt; intArray[i] &lt;&lt; <span class="hljs-built_in">endl</span> ;
}
<span class="hljs-comment">//&#x91CA;&#x653E;&#x7A7A;&#x95F4;</span>
<span class="hljs-keyword">delete</span> intArray;
</code></pre>
<h2 id="&#x7ED3;&#x6784;&#x4F53;"><a name="&#x7ED3;&#x6784;&#x4F53;" class="anchor-navigation-ex-anchor" href="#&#x7ED3;&#x6784;&#x4F53;"><i class="fa fa-link" aria-hidden="true"></i></a>1.24. &#x7ED3;&#x6784;&#x4F53;</h2>
<pre><code class="lang-c++"><span class="hljs-comment">// &#x7ED3;&#x6784;&#x4F53;&#x7C7B;&#x578B; &#x548C;&#x53D8;&#x91CF; &#x5206;&#x5F00;&#x5B9A;&#x4E49;</span>
<span class="hljs-keyword">struct</span> student {
 <span class="hljs-keyword">char</span> name[<span class="hljs-number">20</span>];    <span class="hljs-comment">//&#x59D3;&#x540D;</span>
 <span class="hljs-keyword">int</span> age;          <span class="hljs-comment">//&#x5E74;&#x9F84;</span>
};
<span class="hljs-keyword">struct</span> student stu1, stu2;

<span class="hljs-comment">// &#x7ED3;&#x6784;&#x4F53;&#x7C7B;&#x578B; &#x548C;&#x53D8;&#x91CF; &#x540C;&#x65F6;&#x5B9A;&#x4E49;</span>
<span class="hljs-keyword">struct</span> student {
 <span class="hljs-keyword">char</span> name[<span class="hljs-number">20</span>];
 <span class="hljs-keyword">int</span> age;
} stu1, stu2;
<span class="hljs-keyword">struct</span> student stu3;
</code></pre>
<h2 id="union-&#x8054;&#x5408;&#x4F53;"><a name="union-&#x8054;&#x5408;&#x4F53;" class="anchor-navigation-ex-anchor" href="#union-&#x8054;&#x5408;&#x4F53;"><i class="fa fa-link" aria-hidden="true"></i></a>1.25. Union &#x8054;&#x5408;&#x4F53;</h2>
<pre><code class="lang-c++">&#x6240;&#x6709;&#x6210;&#x5458;&#x53D8;&#x91CF;&#x5171;&#x4EAB;&#x4E00;&#x4E2A;&#x5185;&#x5B58;,
&#x5BF9;&#x4E8E;Union&#x7684;&#x4E0D;&#x540C;&#x6210;&#x5458;&#x8D4B;&#x503C;&#xFF0C;&#x5C06;&#x4F1A;&#x5BF9;&#x5176;&#x4ED6;&#x6210;&#x5458;&#x91CD;&#x5199;&#xFF0C;&#x539F;&#x6765;&#x6210;&#x5458;&#x7684;&#x503C;&#x5C31;&#x4E0D;&#x5B58;&#x5728;&#x4E86;&#x3002;
&#x5176;&#x4ED6;&#x7684;&#x7528;&#x6CD5;&#x53C2;&#x8003;<span class="hljs-keyword">struct</span> &#x3002;
</code></pre>
<h2 id="enum-&#x679A;&#x4E3E;"><a name="enum-&#x679A;&#x4E3E;" class="anchor-navigation-ex-anchor" href="#enum-&#x679A;&#x4E3E;"><i class="fa fa-link" aria-hidden="true"></i></a>1.26. enum &#x679A;&#x4E3E;</h2>
<pre><code class="lang-xml">//&#x679A;&#x4E3E;&#x503C;&#x9ED8;&#x8BA4;&#x4ECE;0&#x4F9D;&#x6B21;&#x8D4B;&#x503C;
enum color
{
  red,
  green,
  blue
};
color paint = red;

// red&#x4E3A;0 &#xFF0C; green&#x4E3A;5 &#xFF0C; blue&#x4E3A;6
enum color
{
  red,
  green = 5,
  blue 
} paint;
</code></pre>
<h2 id="&#x522B;&#x540D;"><a name="&#x522B;&#x540D;" class="anchor-navigation-ex-anchor" href="#&#x522B;&#x540D;"><i class="fa fa-link" aria-hidden="true"></i></a>1.27. &#x522B;&#x540D;</h2>
<pre><code class="lang-c++">&#x7C7B;&#x578B;&#x522B;&#x540D;&#x53EF;&#x4EE5;&#x7528;&#x6765;&#x964D;&#x4F4E;&#x539F;&#x59CB;&#x7C7B;&#x578B;&#x957F;&#x5EA6;&#x6216;&#x5BB9;&#x6613;&#x6DF7;&#x6DC6;&#x7684;&#x7C7B;&#x578B;&#x540D;&#x79F0;&#x3002;&#x5728;C++&#x4E2D;&#xFF0C;&#x4EFB;&#x4F55;&#x6709;&#x6548;&#x7684;&#x7C7B;&#x578B;&#x90FD;&#x53EF;&#x4EE5;&#x6709;&#x522B;&#x540D;&#x3002;
<span class="hljs-comment">// WORD &#x662F; int&#x7684;&#x522B;&#x540D;</span>
<span class="hljs-keyword">typedef</span> <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> WORD;
</code></pre>
<h2 id="&#x7C7B;class-&#x3001;&#x5BF9;&#x8C61;"><a name="&#x7C7B;class-&#x3001;&#x5BF9;&#x8C61;" class="anchor-navigation-ex-anchor" href="#&#x7C7B;class-&#x3001;&#x5BF9;&#x8C61;"><i class="fa fa-link" aria-hidden="true"></i></a>1.28. &#x7C7B;class &#x3001;&#x5BF9;&#x8C61;</h2>
<pre><code class="lang-xml">C++&#x4E2D;&#x83B7;&#x5F97;&#x5BF9;&#x8C61;&#x6709;&#x4E24;&#x79CD;&#x65B9;&#x6CD5;
1&#x3001;&#x901A;&#x8FC7;new&#x83B7;&#x5F97;
2&#x3001;&#x76F4;&#x63A5;&#x7533;&#x660E;&#x83B7;&#x5F97;&#x3002;
&#x8FD9;&#x79CD;&#x65B9;&#x6CD5;&#x8DDF;java&#x7684;&#x5BF9;&#x8C61;&#x83B7;&#x5F97;&#x533A;&#x522B;&#x5F88;&#x5927;&#x3002;java&#x662F;&#x4E0D;&#x4F1A;&#x5206;&#x914D;&#x7A7A;&#x95F4;&#x7684;&#xFF0C;&#x6B64;&#x65F6;&#x8C03;&#x7528;&#x4F1A;&#x7A7A;&#x6307;&#x9488;&#x3002;
&#x800C;C++&#x662F;&#x58F0;&#x660E;&#x5BF9;&#x8C61;&#x5E76;&#x4E3A;&#x5176;&#x5206;&#x914D;&#x4E86;&#x7A7A;&#x95F4;&#x7684;&#x3002; 

new&#x51FA;&#x6765;&#x7684;&#x5BF9;&#x8C61;&#x7C7B;&#x4F3C;&#x4E8E;&#x7533;&#x8BF7;&#x7A7A;&#x95F4;&#xFF0C;&#x56E0;&#x6B64;&#x9700;&#x8981;delete&#x9500;&#x6BC1;&#xFF0C;&#x800C;&#x76F4;&#x63A5;&#x58F0;&#x660E;&#x7684;&#x5BF9;&#x8C61;&#x5219;&#x5728;&#x4F7F;&#x7528;&#x5B8C;&#x76F4;&#x63A5;&#x9500;&#x6BC1;&#x3002;
new&#x51FA;&#x6765;&#x7684;&#x5BF9;&#x8C61;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x6307;&#x9488;&#x63A5;&#x6536;&#xFF0C;&#x800C;&#x76F4;&#x63A5;&#x58F0;&#x660E;&#x7684;&#x4E0D;&#x7528;&#x3002;
</code></pre>
<pre><code class="lang-text">c++ &#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x8C03;&#x7528;&#x5916;&#x90E8;&#x6587;&#x4EF6;&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x4E3A;&#x4EC0;&#x4E48;&#x8FD8;&#x8981;&#x7C7B;&#x548C;&#x5BF9;&#x8C61;&#xFF1F; &#xFF08;Java&#x53EA;&#x80FD;&#x8C03;&#x7528;static&#x7C7B;&#x578B;&#x7684;&#x5916;&#x90E8;&#x6587;&#x4EF6;&#x51FD;&#x6570;&#xFF09;
&#x7B54;&#xFF1A;c++ &#x867D;&#x7136;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x8C03;&#x7528;&#x5916;&#x90E8;&#x6587;&#x4EF6;&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x4F46;&#x662F;&#x51FD;&#x6570;&#x5982;&#x679C;&#x5F88;&#x591A;&#x7684;&#x8BDD;&#xFF0C;&#x4E0D;&#x80FD;&#x76F4;&#x89C2;&#x5730;&#x77E5;&#x9053;&#x662F;&#x5C5E;&#x4E8E;&#x54EA;&#x4E2A;&#x6587;&#x4EF6;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x7528;&#x7C7B;&#x6765;&#x8FDB;&#x884C;&#x6765;&#x7BA1;&#x7406;&#x3002;
&#x8FD9;&#x4E5F;&#x662F;c++&#x6BD4;c&#x66F4;&#x65B9;&#x4FBF;&#x7684;&#x5730;&#x65B9;&#x3002;
</code></pre>
<pre><code class="lang-c++">&#x7C7B;&#x7684;&#x5C5E;&#x6027;&#x548C;&#x65B9;&#x6CD5; &#x9ED8;&#x8BA4;&#x8BBF;&#x95EE;&#x7EA7;&#x522B;&#x662F;<span class="hljs-keyword">private</span>&#x3002;
<span class="hljs-keyword">class</span> Student{
    <span class="hljs-keyword">char</span> *name;
    <span class="hljs-keyword">int</span> age;
<span class="hljs-keyword">public</span>:
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">showInfo</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;&#x540D;&#x5B57;=&quot;</span>&lt;&lt; name &lt;&lt; <span class="hljs-string">&quot; &#x5E74;&#x9F84;&quot;</span> &lt;&lt; age  &lt;&lt; <span class="hljs-built_in">endl</span>;
    }
    <span class="hljs-comment">// &#x6784;&#x9020;&#x51FD;&#x6570;</span>
    Student(<span class="hljs-keyword">char</span> *name0, <span class="hljs-keyword">int</span> age0){
        name = name0;
        age = age0;
    }
    <span class="hljs-comment">// &#x666E;&#x901A;&#x51FD;&#x6570;</span>
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">setAge</span><span class="hljs-params">(<span class="hljs-keyword">int</span> age)</span></span>;
    <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">setName</span><span class="hljs-params">(<span class="hljs-keyword">char</span> *name0)</span></span>;
};
<span class="hljs-comment">// &#x5728; &#x7C7B;&#x7684;&#x5916;&#x90E8;&#x5B9A;&#x4E49;&#x51FD;&#x6570;</span>
<span class="hljs-keyword">void</span> Student::setAge(<span class="hljs-keyword">int</span> age0){
    age = age0;
}

<span class="hljs-keyword">void</span> Student::setName(<span class="hljs-keyword">char</span> *name0){
    name = name0;
}

<span class="hljs-comment">// &#x7533;&#x660E;&#x5F0F;&#x83B7;&#x5F97;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x3002; &#x7528;&#x5E26;&#x53C2;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7533;&#x660E;&#x4E86;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;student (&#x540D;&#x5B57;&#x968F;&#x610F;)&#x3002;</span>
<span class="hljs-function">Student <span class="hljs-title">student</span><span class="hljs-params">(<span class="hljs-string">&quot;Aivin&quot;</span>  , <span class="hljs-number">21</span>)</span></span>;  <span class="hljs-comment">// &#x8FD9;&#x4E2A;&#x5BF9;&#x8C61;&#x6B64;&#x65F6;&#x5DF2;&#x7ECF;&#x88AB;&#x5206;&#x914D;&#x4E86;&#x5185;&#x5B58;&#x7A7A;&#x95F4;&#x4E86;&#x3002;&#x5E76;&#x4E0D;&#x4F1A;&#x6709;&#x7A7A;&#x6307;&#x9488; &#x3002;&#x6CE8;&#x610F;&#x4E0E;java&#x7684;&#x533A;&#x522B;&#x3002;</span>
student.setAge(<span class="hljs-number">20</span>);
student.setName(<span class="hljs-string">&quot;&#x5C0F;&#x660E;&quot;</span>);
student.showInfo();

&#x6210;&#x5458;&#x51FD;&#x6570;/ &#x6784;&#x9020;&#x51FD;&#x6570;&#x540E;&#x9762;&#x8DDF; &#x5192;&#x53F7; &#x201C;:&#x201D;&#x8868;&#x793A;&#x7684;&#x662F;&#x8D4B;&#x503C;&#xFF0C;&#x8FD9;&#x662F;c++&#x7684;&#x7279;&#x6027;&#x3002;
A( <span class="hljs-keyword">int</span> aa, <span class="hljs-keyword">int</span> bb ):a(aa),b(bb) { ...}  &#x76F8;&#x5F53;&#x4E8E;  A( <span class="hljs-keyword">int</span> aa, <span class="hljs-keyword">int</span> bb ) { a=aa;b=bb;}
__func__ &#xFF1A;  &#x4E00;&#x4E2A;&#x9884;&#x7F6E;&#x5728;&#x7F16;&#x8BD1;&#x5668;&#x4E2D;&#x7684;&#x5B8F;&#xFF0C;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x8C03;&#x7528;&#x3002;&#x662F;&#x8C03;&#x7528;&#x5B83;&#x7684;&#x6240;&#x5728;&#x51FD;&#x6570;&#x7684;&#x51FD;&#x6570;&#x540D;&#x3002;
</code></pre>
<h2 id="stl"><a name="stl" class="anchor-navigation-ex-anchor" href="#stl"><i class="fa fa-link" aria-hidden="true"></i></a>1.29. STL</h2>
<pre><code class="lang-xml">C++ STL(&#x6807;&#x51C6;&#x6A21;&#x677F;&#x5E93;)&#x662F;&#x4E00;&#x5957;&#x529F;&#x80FD;&#x5F3A;&#x5927;&#x7684;&#x6A21;&#x677F;&#x7C7B;&#xFF0C;&#x63D0;&#x4F9B;&#x4E86;&#x901A;&#x7528;&#x7684;&#x6A21;&#x677F;&#x7C7B;&#x548C;&#x51FD;&#x6570;&#xFF0C;
&#x8FD9;&#x4E9B;&#x6A21;&#x677F;&#x7C7B;&#x548C;&#x51FD;&#x6570;&#x53EF;&#x4EE5;&#x5B9E;&#x73B0;&#x591A;&#x79CD;&#x6D41;&#x884C;&#x548C;&#x5E38;&#x7528;&#x7684;&#x7B97;&#x6CD5;&#x548C;&#x6570;&#x636E;&#x7ED3;&#x6784;&#xFF0C;&#x5982;&#x5411;&#x91CF;&#x3001;&#x94FE;&#x8868;&#x3001;&#x961F;&#x5217;&#x3001;&#x6808;&#x3002;
</code></pre>
<h2 id="&#x683C;&#x5F0F;&#x5316;&#x65F6;&#x95F4;"><a name="&#x683C;&#x5F0F;&#x5316;&#x65F6;&#x95F4;" class="anchor-navigation-ex-anchor" href="#&#x683C;&#x5F0F;&#x5316;&#x65F6;&#x95F4;"><i class="fa fa-link" aria-hidden="true"></i></a>1.30. &#x683C;&#x5F0F;&#x5316;&#x65F6;&#x95F4;</h2>
<pre><code class="lang-c++"><span class="hljs-comment">// time_t &#x53EA;&#x80FD;&#x7CBE;&#x786E;&#x5230;&#x79D2;</span>
<span class="hljs-keyword">time_t</span> t = time(<span class="hljs-number">0</span>);
<span class="hljs-keyword">char</span> tmp[<span class="hljs-number">64</span>];
strftime(tmp, <span class="hljs-keyword">sizeof</span>(tmp), <span class="hljs-string">&quot;%Y-%m-%d %H:%M:%S&quot;</span>,localtime(&amp;t) );
LOGI(<span class="hljs-string">&quot;&#x5F53;&#x524D;&#x65F6;&#x95F4;&#x662F;&#xFF1A;%s&quot;</span> , tmp) ;
</code></pre>
<p><br></p>
<h2 id="&#x6790;&#x6784;&#x51FD;&#x6570;"><a name="&#x6790;&#x6784;&#x51FD;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x6790;&#x6784;&#x51FD;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>1.31. &#x6790;&#x6784;&#x51FD;&#x6570;</h2>
<pre><code class="lang-xml">c++&#x4E2D;&#x51FD;&#x6570;&#x524D;&#x52A0; ~ &#x662F;&#x8868;&#x793A;&#x6B64;&#x51FD;&#x6570;&#x662F;&#x6790;&#x6784;&#x51FD;&#x6570;&#x3002;
&#x7528;&#x6765;&#x91CA;&#x653E;&#x7A0B;&#x5E8F;&#x8FD0;&#x884C;&#x4E2D;&#x6CA1;&#x6709;delete&#x6216;&#x8005;free&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x5B8C;&#x6210;&#x626B;&#x5C3E;&#x5DE5;&#x4F5C;&#xFF0C;
&#x4E00;&#x822C;&#x7684;&#x521B;&#x5EFA;&#x7C7B;&#x5982;&#x679C;&#x4E0D;&#x5199;&#x6790;&#x6784;&#x51FD;&#x6570;&#x4F1A;&#x8C03;&#x7528;&#x7CFB;&#x7EDF;&#x9ED8;&#x8BA4;&#x7684;&#x6790;&#x6784;&#x51FD;&#x6570;&#xFF0C;
&#x5982;&#x679C;&#x7528;&#x6237;&#x6709;&#x58F0;&#x660E;&#x548C;&#x5B9A;&#x4E49;&#xFF0C;&#x5219;&#x8C03;&#x7528;&#x7528;&#x6237;&#x7684;
/***&#x6784;&#x9020;&#x51FD;&#x6570;*/
WlJavaCall(_JavaVM *javaVM, JNIEnv *env, jobject *jobj);

/***&#x6790;&#x6784;&#x51FD;&#x6570;*/
~WlJavaCall();
</code></pre>
<h2 id="stdstring-&#x5B57;&#x7B26;&#x4E32;"><a name="stdstring-&#x5B57;&#x7B26;&#x4E32;" class="anchor-navigation-ex-anchor" href="#stdstring-&#x5B57;&#x7B26;&#x4E32;"><i class="fa fa-link" aria-hidden="true"></i></a>1.32. std::string &#x5B57;&#x7B26;&#x4E32;</h2>
<pre><code class="lang-text">std::string::npos // &#x5E38;&#x6570;, &#x7B49;&#x4E8E;size_type&#x7C7B;&#x578B;&#x53EF;&#x4EE5;&#x8868;&#x793A;&#x7684;&#x6700;&#x5927;&#x503C;,&#x7528;&#x6765;&#x8868;&#x793A;&#x4E00;&#x4E2A;&#x4E0D;&#x5B58;&#x5728;&#x7684;&#x4F4D;&#x7F6E;&#x3002;
std::string audio_codec_name(&quot;aaaaaa&quot;)  // &#x65B0;&#x5EFA;&#x53D8;&#x91CF;audio_codec_name&#xFF0C;&#x521D;&#x59CB;&#x5316;&#x4E3A;aaaaaa&#x3002;
</code></pre>
<h2 id="stdpair"><a name="stdpair" class="anchor-navigation-ex-anchor" href="#stdpair"><i class="fa fa-link" aria-hidden="true"></i></a>1.33. std::pair</h2>
<pre><code class="lang-text">// &#x952E;&#x503C;&#x5BF9;
&#x53EF;&#x4EE5;&#x7528;&#x8FC7; first&#x548C;second&#x8BBF;&#x95EE;&#x7B2C;&#x4E00;&#x4E2A;&#x548C;&#x7B2C;&#x4E8C;&#x4E2A;&#x5143;&#x7D20;
</code></pre>
<h2 id="stdmap"><a name="stdmap" class="anchor-navigation-ex-anchor" href="#stdmap"><i class="fa fa-link" aria-hidden="true"></i></a>1.34. std::map</h2>
<pre><code class="lang-text">insert( )  // &#x63D2;&#x5165;&#x5143;&#x7D20;
find( ) // &#x6839;&#x636E;key &#x67E5;&#x627E;&#xFF0C;
end( ) // &#x6307;&#x5411;map&#x7684;&#x672B;&#x5C3E; , &#x8868;&#x793A;&#x6CA1;&#x6709;&#x627E;&#x5230;
erase( ) // &#x5220;&#x9664;&#x4E00;&#x4E2A;&#x5143;&#x7D20;
</code></pre>
<h2 id="&#x94FE;&#x8868;"><a name="&#x94FE;&#x8868;" class="anchor-navigation-ex-anchor" href="#&#x94FE;&#x8868;"><i class="fa fa-link" aria-hidden="true"></i></a>1.35. &#x94FE;&#x8868;</h2>
<pre><code class="lang-text">std::list  
push_back( )  //&#x5728;&#x672B;&#x5C3E;&#x63D2;&#x5165;&#x5143;&#x7D20;
sort( ) // &#x4EE5;&#x81EA;&#x5B9A;&#x4E49;&#x89C4;&#x5219;&#x6392;&#x5E8F;
begin()  //&#x8FD4;&#x56DE;&#x6307;&#x5411;&#x5BB9;&#x5668;&#x6700;&#x5F00;&#x59CB;&#x4F4D;&#x7F6E;&#x6570;&#x636E;&#x7684;&#x6307;&#x9488;
c.end() // &#x8FD4;&#x56DE;&#x6307;&#x5411;&#x5BB9;&#x5668;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x5355;&#x5143;+1&#x7684;&#x6307;&#x9488;
clear( )  // &#x79FB;&#x9664;&#x6240;&#x6709;&#x5143;&#x7D20;&#xFF0C;&#x5BB9;&#x5668;&#x6E05;&#x7A7A;&#x3002;
</code></pre>
<h2 id="c&#x961F;&#x5217;-stddeque"><a name="c&#x961F;&#x5217;-stddeque" class="anchor-navigation-ex-anchor" href="#c&#x961F;&#x5217;-stddeque"><i class="fa fa-link" aria-hidden="true"></i></a>1.36. c++&#x961F;&#x5217; std::deque</h2>
<p>&#x4E00;&#x79CD;&#x5148;&#x8FDB;&#x5148;&#x51FA;(FIFO)&#x7684;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x3002;</p>
<h3 id="&#x961F;&#x5217;&#x4F7F;&#x7528;"><a name="&#x961F;&#x5217;&#x4F7F;&#x7528;" class="anchor-navigation-ex-anchor" href="#&#x961F;&#x5217;&#x4F7F;&#x7528;"><i class="fa fa-link" aria-hidden="true"></i></a>1.36.1. &#x961F;&#x5217;&#x4F7F;&#x7528;</h3>
<pre><code class="lang-c++"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-string">&quot;queue&quot;</span></span>
<span class="hljs-built_in">std</span>::<span class="hljs-built_in">queue</span>&lt;T&gt; <span class="hljs-built_in">queue</span>; <span class="hljs-comment">// &#x521B;&#x5EFA;&#x961F;&#x5217; &#xFF0C;&#x4E0D;&#x9700;&#x8981;alloc&#x4E4B;&#x7C7B;&#x64CD;&#x4F5C;</span>
<span class="hljs-built_in">queue</span>.push(t);<span class="hljs-comment">//&#x5165;&#x961F;</span>
AVFrame *avFrame1 = queueFrame.front();<span class="hljs-comment">// &#x8FD4;&#x56DE;&#x961F;&#x5217;&#x4E2D;&#x7B2C;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x3002;&#x4E0D;&#x4F1A;&#x5220;&#x9664;&#x3002;</span>
queueFrame.pop();<span class="hljs-comment">// &#x5220;&#x9664;&#x7B2C;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x3002;&#x6CA1;&#x6709;&#x8FD4;&#x56DE;</span>
AVFrame *avFrame2=queueFrame.back();<span class="hljs-comment">// &#x8FD4;&#x56DE;&#x961F;&#x5217;&#x4E2D;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x5143;&#x7D20;</span>
push_back( ) <span class="hljs-comment">//  &#x5728;&#x672B;&#x5C3E;&#x4F4D;&#x7F6E;&#x63D2;&#x5165;&#x5143;&#x7D20;</span>
at()  <span class="hljs-comment">// &#x8FD4;&#x56DE;&#x7D22;&#x5F15;&#x4E3A;pos&#x7684;&#x4F4D;&#x7F6E;&#x7684;&#x5143;&#x7D20;</span>
</code></pre>
<h2 id="&#x7F6E;&#x7A7A;&#x64CD;&#x4F5C;-void"><a name="&#x7F6E;&#x7A7A;&#x64CD;&#x4F5C;-void" class="anchor-navigation-ex-anchor" href="#&#x7F6E;&#x7A7A;&#x64CD;&#x4F5C;-void"><i class="fa fa-link" aria-hidden="true"></i></a>1.37. &#x7F6E;&#x7A7A;&#x64CD;&#x4F5C; (void)</h2>
<pre><code class="lang-text">SLresult result;
(void) result; // &#x8FD9;&#x6837;&#x7684;&#x5199;&#x6CD5;&#x662F;&#x5C06;result&#x7ED3;&#x679C;&#x7F6E;&#x7A7A;&#xFF1F;
</code></pre>
<h2 id="&#x591A;&#x7EBF;&#x7A0B;"><a name="&#x591A;&#x7EBF;&#x7A0B;" class="anchor-navigation-ex-anchor" href="#&#x591A;&#x7EBF;&#x7A0B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.38. &#x591A;&#x7EBF;&#x7A0B;</h2>
<pre><code class="lang-c++"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;thread&gt;</span></span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">func</span><span class="hljs-params">(<span class="hljs-keyword">int</span> a, <span class="hljs-built_in">string</span> msg)</span>
</span>{
    this_thread::sleep_for(chrono::seconds(<span class="hljs-number">2</span>));<span class="hljs-comment">// &#x7EBF;&#x7A0B;&#x4F11;&#x7720;</span>
    <span class="hljs-built_in">cout</span> &lt;&lt; a &lt;&lt; <span class="hljs-string">&quot; &quot;</span> &lt;&lt; msg  &lt;&lt; <span class="hljs-built_in">endl</span>;
}

thread::id mainThreadId = this_thread::get_id();
<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;&#x4E3B;&#x7EBF;&#x7A0B;Id=&quot;</span> &lt;&lt; mainThreadId &lt;&lt; <span class="hljs-built_in">endl</span>;
<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;CPU&#x6570;&#x91CF;= &quot;</span> &lt;&lt; thread::hardware_concurrency() &lt;&lt; <span class="hljs-built_in">endl</span>;


<span class="hljs-function">thread <span class="hljs-title">t1</span><span class="hljs-params">(func,  <span class="hljs-number">2</span>, <span class="hljs-string">&quot;&#x51FD;&#x6570;&#x53C2;&#x6570;&quot;</span>)</span></span>;            <span class="hljs-comment">//&#x521B;&#x5EFA;&#x7EBF;&#x7A0B;&#x5BF9;&#x8C61;t1,&#x7ED1;&#x5B9A;&#x7EBF;&#x7A0B;&#x51FD;&#x6570;&#x4E3A;func</span>
<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;&#x5B50;&#x7EBF;&#x7A0B;Id=&quot;</span> &lt;&lt; t1.get_id() &lt;&lt; <span class="hljs-built_in">endl</span>;<span class="hljs-comment">//&#x8F93;&#x51FA;t1&#x7684;&#x7EBF;&#x7A0B;ID</span>
<span class="hljs-comment">//t1.join();  &#x7B49;&#x5F85; t1&#x7EBF;&#x7A0B;&#x6267;&#x884C;&#x5B8C;&#x6BD5;&#x518D;&#x5F80;&#x4E0B;&#x9762;&#x6267;&#x884C;</span>
t1.detach();&#x4E0D;&#x7528;&#x7BA1;t1&#x662F;&#x5426;&#x6267;&#x884C;&#x5B8C; &#x5373;&#x53EF;&#x5F80;&#x4E0B;&#x6267;&#x884C;

<span class="hljs-comment">//&#x4EE5;lambda&#x8868;&#x8FBE;&#x5F0F;&#x4F5C;&#x4E3A;&#x88AB;&#x5E2E;&#x9876;&#x7684;&#x7EBF;&#x7A0B;&#x51FD;&#x6570;</span>
<span class="hljs-function">thread <span class="hljs-title">t4</span><span class="hljs-params">( [](<span class="hljs-keyword">int</span> a, <span class="hljs-built_in">string</span> msg)</span>
</span>{
  this_thread::sleep_for(chrono::seconds(<span class="hljs-number">3</span>));
  <span class="hljs-built_in">cout</span> &lt;&lt; a &lt;&lt; <span class="hljs-string">&quot; &quot;</span> &lt;&lt; msg  &lt;&lt; <span class="hljs-built_in">endl</span>;
}, <span class="hljs-number">4</span>, <span class="hljs-string">&quot;lambda&#x8868;&#x8FBE;&#x5F0F;&#x5F62;&#x5F0F;&#x521B;&#x5EFA;&#x5B50;&#x7EBF;&#x7A0B;&quot;</span>);
t4.join();

getchar();
</code></pre>
<h2 id="&#x6587;&#x4EF6;&#x64CD;&#x4F5C;"><a name="&#x6587;&#x4EF6;&#x64CD;&#x4F5C;" class="anchor-navigation-ex-anchor" href="#&#x6587;&#x4EF6;&#x64CD;&#x4F5C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.39. &#x6587;&#x4EF6;&#x64CD;&#x4F5C;</h2>
<h3 id="&#x6743;&#x9650;&#x8BF4;&#x660E;"><a name="&#x6743;&#x9650;&#x8BF4;&#x660E;" class="anchor-navigation-ex-anchor" href="#&#x6743;&#x9650;&#x8BF4;&#x660E;"><i class="fa fa-link" aria-hidden="true"></i></a>1.39.1. &#x6743;&#x9650;&#x8BF4;&#x660E;</h3>
<table>
<thead>
<tr>
<th>&#x6587;&#x4EF6;&#x6253;&#x5F00;&#x6A21;&#x5F0F;</th>
<th>&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td>ios::in</td>
<td>&#x53EA;&#x8BFB;</td>
</tr>
<tr>
<td>ios::out</td>
<td>&#x53EA;&#x5199;</td>
</tr>
<tr>
<td>ios::app</td>
<td>&#x4ECE;&#x6587;&#x4EF6;&#x672B;&#x5C3E;&#x5F00;&#x59CB;&#x5199;&#xFF0C;&#x9632;&#x6B62;&#x4E22;&#x5931;&#x6587;&#x4EF6;&#x4E2D;&#x539F;&#x6765;&#x5C31;&#x6709;&#x7684;&#x5185;&#x5BB9;</td>
</tr>
<tr>
<td>ios::binary</td>
<td>&#x4E8C;&#x8FDB;&#x5236;&#x6A21;&#x5F0F;</td>
</tr>
<tr>
<td>ios::nocreate</td>
<td>&#x6253;&#x5F00;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x65F6;&#xFF0C;&#x5982;&#x679C;&#x6587;&#x4EF6;&#x4E0D;&#x5B58;&#x5728;&#xFF0C;&#x4E0D;&#x521B;&#x5EFA;&#x6587;&#x4EF6;</td>
</tr>
<tr>
<td>ios::noreplace</td>
<td>&#x6253;&#x5F00;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x65F6;&#xFF0C;&#x5982;&#x679C;&#x6587;&#x4EF6;&#x4E0D;&#x5B58;&#x5728;&#xFF0C;&#x521B;&#x5EFA;&#x8BE5;&#x6587;&#x4EF6;</td>
</tr>
<tr>
<td>ios::trunc</td>
<td>&#x6253;&#x5F00;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#xFF0C;&#x7136;&#x540E;&#x6E05;&#x7A7A;&#x5185;&#x5BB9;</td>
</tr>
<tr>
<td>ios::ate</td>
<td>&#x6253;&#x5F00;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x65F6;&#xFF0C;&#x5C06;&#x4F4D;&#x7F6E;&#x79FB;&#x52A8;&#x5230;&#x6587;&#x4EF6;&#x5C3E;</td>
</tr>
</tbody>
</table>
<p><br></p>
<h3 id="&#x8BFB;&#x53D6;-txt"><a name="&#x8BFB;&#x53D6;-txt" class="anchor-navigation-ex-anchor" href="#&#x8BFB;&#x53D6;-txt"><i class="fa fa-link" aria-hidden="true"></i></a>1.39.2. &#x8BFB;&#x53D6; txt</h3>
<pre><code class="lang-c++"><span class="hljs-comment">// #include &lt;windows.h&gt;</span>
<span class="hljs-comment">// &#x89E3;&#x51B3;&#x4E2D;&#x6587;&#x4E71;&#x7801;</span>
<span class="hljs-function"><span class="hljs-built_in">string</span> <span class="hljs-title">UTF8ToGB</span><span class="hljs-params">(<span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span>* str)</span>
</span>{
    <span class="hljs-built_in">string</span> result;
    WCHAR *strSrc;
    LPSTR szRes;

    <span class="hljs-comment">//&#x83B7;&#x5F97;&#x4E34;&#x65F6;&#x53D8;&#x91CF;&#x7684;&#x5927;&#x5C0F;</span>
    <span class="hljs-keyword">int</span> i = MultiByteToWideChar(CP_UTF8, <span class="hljs-number">0</span>, str, <span class="hljs-number">-1</span>, <span class="hljs-literal">NULL</span>, <span class="hljs-number">0</span>);
    strSrc = <span class="hljs-keyword">new</span> WCHAR[i + <span class="hljs-number">1</span>];
    MultiByteToWideChar(CP_UTF8, <span class="hljs-number">0</span>, str, <span class="hljs-number">-1</span>, strSrc, i);

    <span class="hljs-comment">//&#x83B7;&#x5F97;&#x4E34;&#x65F6;&#x53D8;&#x91CF;&#x7684;&#x5927;&#x5C0F;</span>
    i = WideCharToMultiByte(CP_ACP, <span class="hljs-number">0</span>, strSrc, <span class="hljs-number">-1</span>, <span class="hljs-literal">NULL</span>, <span class="hljs-number">0</span>, <span class="hljs-literal">NULL</span>, <span class="hljs-literal">NULL</span>);
    szRes = <span class="hljs-keyword">new</span> CHAR[i + <span class="hljs-number">1</span>];
    WideCharToMultiByte(CP_ACP, <span class="hljs-number">0</span>, strSrc, <span class="hljs-number">-1</span>, szRes, i, <span class="hljs-literal">NULL</span>, <span class="hljs-literal">NULL</span>);

    result = szRes;
    <span class="hljs-keyword">delete</span>[]strSrc;
    <span class="hljs-keyword">delete</span>[]szRes;

    <span class="hljs-keyword">return</span> result;
}

<span class="hljs-built_in">string</span> path = <span class="hljs-string">&quot;D:\\hello.txt&quot;</span>;
ifstream infile;
infile.open(path , ios::in);

<span class="hljs-keyword">char</span> mBuffer[<span class="hljs-number">100</span>];
<span class="hljs-built_in">string</span> msg;

<span class="hljs-keyword">if</span> (infile.is_open())
{
  <span class="hljs-keyword">while</span> (!infile.eof())
  {
    <span class="hljs-comment">// buffer &#x5927;&#x5C0F;</span>
    infile.getline(mBuffer, <span class="hljs-number">200</span>);
    msg = UTF8ToGB(mBuffer);
    <span class="hljs-built_in">cout</span> &lt;&lt; msg &lt;&lt; <span class="hljs-built_in">endl</span>;
  }
}

infile.close();
</code></pre>
<p><br></p>
<h3 id="&#x5199;&#x5165;-txt"><a name="&#x5199;&#x5165;-txt" class="anchor-navigation-ex-anchor" href="#&#x5199;&#x5165;-txt"><i class="fa fa-link" aria-hidden="true"></i></a>1.39.3. &#x5199;&#x5165; txt</h3>
<pre><code class="lang-c++"><span class="hljs-built_in">string</span> path = <span class="hljs-string">&quot;D:\\hello2.txt&quot;</span>;
ofstream outfile;
<span class="hljs-comment">// &#x8FFD;&#x52A0;&#x6A21;&#x5F0F;  ios::app , &#x8986;&#x76D6;&#x6A21;&#x5F0F;   ios::out</span>
outfile.open(path, ios::app);

<span class="hljs-keyword">if</span> (!outfile.is_open())
{
  <span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;&#x6587;&#x4EF6;&#x521B;&#x5EFA;&#x5931;&#x8D25;&quot;</span> &lt;&lt; <span class="hljs-built_in">endl</span>;
  <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}

<span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=<span class="hljs-number">0</span> ;i&lt;<span class="hljs-number">5</span> ;i++)
{
  outfile &lt;&lt; <span class="hljs-string">&quot;&#x5F53;&#x524D;&#x884C;&#x6570;&#xFF1A;&quot;</span> ;
  outfile &lt;&lt; i;
  <span class="hljs-comment">// &#x6362;&#x884C;</span>
  outfile &lt;&lt; <span class="hljs-string">&quot;\n&quot;</span>;

}
outfile.close();
</code></pre>
<p><br><br></p>
<h3 id="&#x4E8C;&#x8FDB;&#x5236;&#x6587;&#x4EF6;-&#x590D;&#x5236;"><a name="&#x4E8C;&#x8FDB;&#x5236;&#x6587;&#x4EF6;-&#x590D;&#x5236;" class="anchor-navigation-ex-anchor" href="#&#x4E8C;&#x8FDB;&#x5236;&#x6587;&#x4EF6;-&#x590D;&#x5236;"><i class="fa fa-link" aria-hidden="true"></i></a>1.39.4. &#x4E8C;&#x8FDB;&#x5236;&#x6587;&#x4EF6; &#x590D;&#x5236;</h3>
<pre><code class="lang-c++"><span class="hljs-comment">/** &#x76EE;&#x6807;&#x6587;&#x4EF6;&#x8DEF;&#x5F84; &#xFF0C; &#x539F;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;*/</span>
<span class="hljs-function"><span class="hljs-keyword">bool</span> <span class="hljs-title">copy_binary_file</span><span class="hljs-params">(<span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> * szDestFile, <span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> * szOrigFile)</span>
</span>{
    <span class="hljs-keyword">bool</span> bRet = <span class="hljs-literal">true</span>;
    <span class="hljs-built_in">std</span>::<span class="hljs-function">ofstream <span class="hljs-title">fout</span><span class="hljs-params">(szDestFile, <span class="hljs-built_in">std</span>::ios::binary | <span class="hljs-built_in">std</span>::ios::app)</span></span>;
    <span class="hljs-built_in">std</span>::<span class="hljs-function">ifstream <span class="hljs-title">fin</span><span class="hljs-params">(szOrigFile, <span class="hljs-built_in">std</span>::ios::binary)</span></span>;
    <span class="hljs-keyword">if</span> (fin.bad())
    {
        bRet = <span class="hljs-literal">false</span>;
    }
    <span class="hljs-keyword">else</span>
    {
        <span class="hljs-keyword">while</span> (!fin.eof())
        {
            <span class="hljs-keyword">char</span> szBuf[<span class="hljs-number">256</span>] = { <span class="hljs-number">0</span> };

            fin.read(szBuf, <span class="hljs-keyword">sizeof</span>(<span class="hljs-keyword">char</span>) * <span class="hljs-number">256</span>);

            <span class="hljs-keyword">if</span> (fout.bad())
            {
                bRet = <span class="hljs-literal">false</span>;
                <span class="hljs-keyword">break</span>;
            }
            fout.write(szBuf, <span class="hljs-keyword">sizeof</span>(<span class="hljs-keyword">char</span>) * <span class="hljs-number">256</span>);
        }
    }

    fin.close();
    fout.close();

    <span class="hljs-keyword">return</span> bRet;
}

<span class="hljs-comment">// &#x6D4B;&#x8BD5;</span>
<span class="hljs-built_in">string</span> originPath = <span class="hljs-string">&quot;D:\\music.mp3&quot;</span>;
<span class="hljs-built_in">string</span> destPath = <span class="hljs-string">&quot;D:\\music2.mp3&quot;</span>;
<span class="hljs-keyword">bool</span> reslut = copy_binary_file( destPath.c_str() , originPath.c_str());
</code></pre>
<h2 id="&#x6DF7;&#x5408;&#x7F16;&#x7A0B;"><a name="&#x6DF7;&#x5408;&#x7F16;&#x7A0B;" class="anchor-navigation-ex-anchor" href="#&#x6DF7;&#x5408;&#x7F16;&#x7A0B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.40. &#x6DF7;&#x5408;&#x7F16;&#x7A0B;</h2>
<p>C&#x7F16;&#x8BD1;&#x5668; &#x548C; C++&#x7F16;&#x8BD1;&#x5668;&#x5BF9;&#x7F16;&#x8BD1;&#x51FD;&#x6570;&#x7B26;&#x53F7;&#x7684;&#x751F;&#x6210;&#x89C4;&#x5219;&#x662F;&#x4E0D;&#x4E00;&#x6837;&#x7684;&#x3002;&#x6240;&#x4EE5;&#x4E0D;&#x80FD;&#x76F4;&#x63A5;&#x4E92;&#x76F8;&#x8C03;&#x7528;&#xFF0C;&#x5FC5;&#x987B;&#x8981;&#x663E;&#x793A;&#x5730;&#x7533;&#x660E;&#x3002;</p>
<h3 id="c-&#x6587;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528;-c&#x4EE3;&#x7801;"><a name="c-&#x6587;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528;-c&#x4EE3;&#x7801;" class="anchor-navigation-ex-anchor" href="#c-&#x6587;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528;-c&#x4EE3;&#x7801;"><i class="fa fa-link" aria-hidden="true"></i></a>1.40.1. c++ &#x6587;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528; c&#x4EE3;&#x7801;</h3>
<pre><code class="lang-c++"><span class="hljs-comment">//__cplusplus&#x662F;cpp&#x4E2D;&#x7684;&#x81EA;&#x5B9A;&#x4E49;&#x5B8F;&#xFF0C; &#x82E5;&#x679C;&#x5B9A;&#x4E49;&#x4E86;&#x8FD9;&#x4E2A;&#x5B8F; &#x5219;&#x8868;&#x793A;&#x8FD9;&#x662F;&#x4E00;&#x6BB5;cpp&#x4EE3;&#x7801;&#x3002;</span>
<span class="hljs-comment">//cfun.h</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">ifdef</span> __cplusplus  </span>
<span class="hljs-keyword">extern</span> <span class="hljs-string">&quot;C&quot;</span> {
<span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span></span>
 <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">cfun</span><span class="hljs-params">()</span></span>;
<span class="hljs-meta">#<span class="hljs-meta-keyword">ifdef</span> __cplusplus  </span>
}
<span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span>  </span>

<span class="hljs-comment">//cfun.c</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-string">&quot;cfun.h&quot;</span>  </span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;stdio.h&gt;</span>  </span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">cfun</span><span class="hljs-params">()</span>
</span>{
    <span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;hello world...&#x6211;&#x662F;c&#x5199;&#x7684;...\n&quot;</span>);
}

<span class="hljs-comment">// main.cpp</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;iostream&gt;</span>  </span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span>  <span class="hljs-string">&quot;cfun.h&quot;</span></span>
<span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> <span class="hljs-built_in">std</span>;
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span>
</span>{
    <span class="hljs-built_in">cout</span> &lt;&lt;<span class="hljs-string">&quot;&#x6211;&#x5728;cpp&#x6587;&#x4EF6; \n&quot;</span>  &lt;&lt; <span class="hljs-built_in">endl</span>;
    cfun();
    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>
<p><br><br></p>
<h3 id="c-&#x6587;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528;-c-&#x4EE3;&#x7801;"><a name="c-&#x6587;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528;-c-&#x4EE3;&#x7801;" class="anchor-navigation-ex-anchor" href="#c-&#x6587;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528;-c-&#x4EE3;&#x7801;"><i class="fa fa-link" aria-hidden="true"></i></a>1.40.2. c &#x6587;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528; c++ &#x4EE3;&#x7801;</h3>
<pre><code class="lang-c++"><span class="hljs-comment">// cppfun.h</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">ifdef</span> __cplusplus  </span>
<span class="hljs-keyword">extern</span> <span class="hljs-string">&quot;C&quot;</span> {
<span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span></span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">cppfunc</span><span class="hljs-params">( )</span></span>;
<span class="hljs-meta">#<span class="hljs-meta-keyword">ifdef</span> __cplusplus  </span>
}
<span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span></span>

<span class="hljs-comment">//cppfun.cpp</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-string">&quot;cppfun.h&quot;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;iostream&gt;</span>  </span>
<span class="hljs-keyword">using</span> <span class="hljs-keyword">namespace</span> <span class="hljs-built_in">std</span>;
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">cppfunc</span><span class="hljs-params">( )</span>
</span>{
    <span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;&#x6211;&#x662F;&#x88AB;cpp &#x6253;&#x5370;&#x7684;\n&quot;</span> &lt;&lt; <span class="hljs-built_in">endl</span>;
}

<span class="hljs-comment">// main.c</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;stdio.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-string">&quot;cppfun.h&quot;</span></span>

<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span>
</span>{
    <span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;&#x6211;&#x5728;c&#x6587;&#x4EF6;&#x4E2D;&#x53D1;&#x8D77;&#x8C03;&#x7528;\n&quot;</span>);
    cppfunc();
    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>
<h2 id="&#x7F51;&#x7EDC;&#x8BBF;&#x95EE;"><a name="&#x7F51;&#x7EDC;&#x8BBF;&#x95EE;" class="anchor-navigation-ex-anchor" href="#&#x7F51;&#x7EDC;&#x8BBF;&#x95EE;"><i class="fa fa-link" aria-hidden="true"></i></a>1.41. &#x7F51;&#x7EDC;&#x8BBF;&#x95EE;</h2>
<p>&#x4E00;&#x822C;&#x7528;<a href="https://github.com/curl/curl" target="_blank">curl</a> &#xFF1F;&#xFF1F;</p>
<h2 id="&#x5176;&#x4ED6;"><a name="&#x5176;&#x4ED6;" class="anchor-navigation-ex-anchor" href="#&#x5176;&#x4ED6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.42. &#x5176;&#x4ED6;</h2>
<pre><code class="lang-text">printf( )  // &#x8F93;&#x51FA;&#x5230;&#x5C4F;&#x5E55;&#xFF0C;&#x7528;&#x6765;&#x505A;&#x6253;&#x5370;&#x4FE1;&#x606F;
sprintf()  // &#x8F93;&#x51FA;&#x5230;&#x6307;&#x5B9A;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x6216;&#x6570;&#x7EC4;&#x4E2D;&#xFF0C;&#x7528;&#x6765;&#x683C;&#x5F0F;&#x5316;&#x5B57;&#x7B26;&#x4E32;&#x3002;
char* config = new char[strlen(filter_config) + 1];
sprintf(config, &quot;%s%c&quot;, filter_config, 0);
</code></pre>
<footer class="page-footer"><span class="copyright">&#x65E0;&#x7248;&#x6743; &#x53EF;&#x4EE5;&#x65E0;&#x9650;&#x5236;&#x4F7F;&#x7528;&#xFF01; all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x66F4;&#x65B0;&#x65F6;&#x95F4;&#xFF1A;
2020-08-20 16:58:48
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../c语言/c基础.html" class="navigation navigation-prev " aria-label="Previous page: c基础">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="c++基础.html" class="navigation navigation-next " aria-label="Next page: c++基础">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"c++","level":"1.4","depth":1,"next":{"title":"c++基础","level":"1.4.1","depth":2,"path":"chinese/c++/c++基础.md","ref":"chinese/c++/c++基础.md","articles":[]},"previous":{"title":"c基础","level":"1.3.1","depth":2,"path":"chinese/c语言/c基础.md","ref":"chinese/c语言/c基础.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-plus","todo","anchor-navigation-ex","copy-code-button","versions-select","fontsettings","sharing","tbfed-pagefooter","donate","local-video","splitter","edit-link","expandable-chapters","favicon","theme-comscore","local-video"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"无版权 可以无限制使用！","modify_label":"该文件更新时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"todo":{},"splitter":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"versions-select":{"type":"branches"},"donate":{"alipay":"https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201803011956_osChina_支付宝收款码.png","alipayText":"支付宝打赏","button":"打赏","title":"","wechat":"https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201803011956_osChina_微信收款码.png","wechatText":"微信打赏"},"fontsettings":{"family":"sans","size":2,"theme":"sepia"},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"favicon":{"shortcut":"assets/images/favicon.ico","bookmark":"assets/images/favicon.ico"},"theme-comscore":{},"local-video":{},"copy-code-button":{},"versions":{"options":[{"value":"https://www.aivin666.cn/java_android/","text":"v1.0"}]},"sharing":{"all":["facebook","google","twitter","weibo","instapaper"],"facebook":false,"google":true,"instapaper":false,"twitter":false,"vk":false,"weibo":true},"edit-link":{"label":"托管页面","base":"https://www.baidu.com/"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"Aivin","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Aivin开发笔记","language":"zh-hans","gitbook":"*","description":"Aivin开发笔记"},"file":{"path":"chinese/c++/c++基础.md","mtime":"2020-08-20T08:58:48.865Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-08-20T09:02:41.305Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-versions-select/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-local-video/video.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

